ftos.formulaEngine.run
IMPORTANT!
Starting with v24.3.0, this is renamed from runCalculation to ftos.formulaEngine.run.
Starting with v24.3.0, this is renamed from runCalculation to ftos.formulaEngine.run.
Runs a Formula Engine calculation on a set of input arguments.
This is a business logic method for business service components.
Syntax
Copy
ftos.formulaEngine.run(functionName : string, parameter : any, options: IFtosRunFormulaOption): IFtosFormulaResult;
| Parameter | Type | Description |
|---|---|---|
| functionName | string | Name of the formula. |
| parameter | any | Set of arguments to be processed by the Formula Engine calculation. These must match the corresponding formula input set up in Formula Engine. |
| options | IFtosRunFormulaOption | Set of options for running the formula. |
Return Value
Returns a IFtosFormulaResult object, which allows you to retrieve the formula result.
Interfaces
IFtosRunFormulaOption
Set of options for executing a business formula.
Copy
interface IFtosRunFormulaOption {
referenceDate?: Date;
}
| Property | Type | Description |
|---|---|---|
referenceDate(optional)
|
Date | The reference date applied when executing the formula. This allows referencing closed versions of a formula that were active before the currently active version. |
IFtosFormulaResult
The outcome of executing a business formula. It stores both the inputs provided to the formula and the resulting computed value.
Copy
interface IFtosFormulaResult {
input: any;
result: any;
}
| Property | Type | Description |
|---|---|---|
input
|
any | Arguments that were passed to the formula for execution. |
result
|
any | The value produced as a result of processing the inputs. |
Examples
This example:
- Runs the predefined MonthlyPayment formula, which uses the NumberOfPayments, InterestRate, and Principal input parameters.
- The values used for the input parameters are: 60 months, 0.0084916 monthly interest rate, and a 30000 USD principal.
- Stores the result in a variable called monthlyPayment and displays it in a warning message. For details on how to display messages, see ftos.context.response.setMessage.
Copy
let monthlyPayment = ftos.formulaEngine.run('MonthlyPayment', {'NumberOfPayments': 60, 'InterestRate': 0.0084916, 'Principal': 30000}, {}).result;
ftos.context.response.setMessage('Your monthly payment is: ' + JSON.stringify(monthlyPayment));