ftos.formulaEngine.resolveInputDataMapping
Retrieves business formula inputs based on a predefined formula parameter mapping. The formula parameter mapping matches the formula input arguments to the attributes of an entity.
This is a business logic method for business service components.
Syntax
Copy
ftos.formulaEngine.resolveInputDataMapping(dataMappingName: string, entityId: string): any;
| Parameter | Type | Description |
|---|---|---|
dataMappingName
|
string | Name of the formula parameter mapping you wish to apply. |
entityId
|
string | Primary key of the entity record that holds the attribute values you wish to map to the formula inputs. The record must belong to the master entity defined in the mapping. |
Return Value
Returns a JSON object containing the name-value pairs of the mapped formula input arguments.
Copy
{"firstName":"John", "lastName":"Doe", "dateOfBirth":"1980-08-05T15:03:00"}
Example
This example:
- Retrieves 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.
- Displays the result in a warning message using ftos.context.response.setMessage.
Copy
var formulaInput = ftos.formulaEngine.resolveInputDataMapping('myFPM', ftos.context.id);
var monthlyPayment = ftos.formulaEngine.run('MonthlyPayment', formulaInput, {}).result;
ftos.context.response.setMessage('Your monthly payment is: ' + JSON.stringify(monthlyPayment));