Calculator

The calculator allows custom code to operate on records

Praise Magidi avatar
Written by Praise Magidi
Updated over a week ago

In any process, there is sometimes a need for custom calculations and code. The calculator step in Synatic allows you to add custom Javascript code to a Flow.

Adding the Calculator Step

To add a calculator step, navigate to the Steps palette, and drag and drop the step at the desired location on the flow:

Adding Custom Code

When adding the calculator, you can add code to modify and operate on records as you like. The value you return must be the current record, including your operations. Your return value will then replace the original record.

The calculator step has access to the Processing Object, exposed in the calculator as the parameter input. Typically, you would read the current record value from input.record and perform any calculations and operations you need. The fields available on input.record will be those from your data source.

The example below shows a sales percentages calculation based on data from the record and then added to the record:

Using Parameters

You can use Parameters in your custom code. To use them, you need to first indicate in the "Load Parameters" box (above the code block) the parameters you need to use in the code block:

You must use the full path of the parameter when loading them. The full path of a parameter is shown in its infobox:

The loaded parameters are then available to your code through the loadedParameters dictionary. Each parameter's full pathname is the key so that you can access the parameter value through index notation, e.g., loadedParameters["full-parameter-path"]


Options

None.


Advanced Mode Options

None.


Limitations and known issues

None.


Useful Tutorials

Revisit the Getting Started page for a refresher.

Read more about Steps here.

Did this answer your question?