ftos.formulaEngine.resolveOutputDataMapping
Populates an entity record using the outputs defined by a formula parameter mapping for reference. This is useful to save the results of a business formula to an entity.
This is a business logic method for business service components.
Syntax
Copy
ftos.formulaEngine.resolveOutputDataMapping(
dataMappingName: string,
entityId: string,
input: any,
): void
| Parameter | Type | Description |
|---|---|---|
dataMappingName
|
string | Name of the output formula parameter mapping used to map the populated values to the entity attributes. |
entityId
|
string | Primary key of the entity record that you wish to populate. The record must belong to the master entity defined in the mapping. |
input
|
any | JSON key-value pairs you wish to save to the entity record. The values will be mapped to the corresponding entity attributes based on the dataMappingName parameter. |
Example
This example:
- Uses ftos.formulaEngine.resolveInputDataMapping to retrieve the formula inputs by applying the myFPM input mapping on the current entity record (ftos.context.id).
- Saves the mapped inputs in the formulaInput variable.
- Uses ftos.formulaEngine.run to run the MonthlyPayment formula on the retrieved inputs.
- Stores the formula result in the monthlyPayment variable.
- Saves the monthly payment in the current entity record using the myFPM output mapping for reference.
Copy
var formulaInput = ftos.formulaEngine.resolveInputDataMapping('myFPM', ftos.context.id);
var monthlyPayment = ftos.formulaEngine.run('MonthlyPayment', formulaInput, {}).result;
ftos.formulaEngine.resolveOutputDataMapping('myFPM', ftos.context.id, monthlyPayment);