All Collections
Steps
Mapper Steps
Calculator Mapper Step
Calculator Mapper Step

The calculator is used for custom JavaScript code to manipulate or transform 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 Mapper step in Synatic is used to add custom Javascript code to manipulate or transform records in a flow. The Calculator mapper step using synchronous code.

Adding the Calculator Step

To add a Calculator Mapper step in a flow, follow the below instructions:

1. Click on the highlighted icon as shown in the below image. The Record generator source step is used as an example of a source step.

2. The below page will appear. Select or search for a step to pull out the source data. Click on Calculator as shown in the image below.

Using the Calculator Mapper Step

Javascript ode can be added to modify and operate on records as required when the Calculator step is added. The value returned must be the current record, including the operations. The return value will then replace the original record.

The Calculator Mapper step has access to the Processing Object, exposed in the calculator as the parameter input which also contains detailed flow field information. Typically, the current record value is read from input.record and performs any calculations and operations needed. The available fields on input.record will be those from the data source.

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

Validating Code in the Calculator Mapper Step

There are two ways to validate code in the Calculator Mapper Step:

  1. Validate Flow Button

  2. Validate Flow Feature

For more information on the different ways to validate code in the Calculator Mapper step, click on the link below:

Using Parameters in the Calculator Mapper Step

A Parameter is a value, object, or code snippet used to simplify configuration, facilitate the reuse of common info, and provide extra security, through encryption.

There are three ways in which parameters can be used in the Calculator Mapper step:

1. Normal text parameter.

2. Record parameter.

3. Date parameter.

For more information on the different ways parameters are used, click on the link below:

Loading Parameters

Parameters can be used in the custom code. To use them, first indicate the parameters required in the "Load Parameters" box (above the code block) to use in the code block. Use the full path of the parameter when loading them.

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 by using backticks instead of quotation marks, e.g., ${loadedParameters[text in the parameter]}


Useful Tutorials

Revisit the Getting Started page for a refresher.

Read more about Steps here.

Did this answer your question?