SMOP (Small Operations)
Last updated
Last updated
We often need to modify a parameter before it is referenced in a flow. This happens, for example, when we are looking for a substring within a string or need to add a value to a numeric parameter. For that, there are the SMOPs (Small Operations) feature, which allows you create small operations directly in the field where the parameters are referenced. This means that every operation is executed and its result is passed as a parameter to the module.
SMOP is a data transformation feature that, using , allows you to perform less complex operations with parameters from an platform`s flow.
Some operations with parameters that we can perform in a flow using the SMOP functionality:
Adding two numbers, such as an offset and a rowCount, when reading from a database
Concatenate two strings or extract a pattern from one of them
Changing the data type of a parameter, such as converting a string to a number
With SMOP, whenever a parameter is referenced, it is possible to perform small operations using the data obtained from the flow.
The ideal operations for this functionality have low complexity, so you can transform data using only one line of code. The syntax is JSONata, just like in the Data Transformation module.
The SMOP feature is available for modules with REST, Database and E-mail authentication, and is present in almost all .
The following examples describe small operations (expressions) that can be executed, whose JSONata code is limited to one line and returns only one output element, even if that element is an array:
1
$length(param1)
12
number
2
param1 + param2
15
number
3
param1 + param2
15
number
4
param1 > param2
VERDADEIRO
Boolean
5
$split(param1, " ")
Array
6
$number(param1)
123.45
Number
7
param1[param2]
1
number
Access to the configuration of SMOPs is made during the configuration of the operation of a compatible module, at the stage of editing a flow.
To create an SMOP, follow the steps below:
Click on "Edit" for the desired and compatible module. Then click on the plus sign "+" located in the parameter settings block:
The SMOP creation window will be displayed:
param1 (optional): the original parameter that you want to manipulate must be dragged into this field, and it can be either a flow parameter or a parameter from the preceding flow components. You can also create SMOPs using JSONata operations that do not require parameters
value (optional): if the param informed is a flow parameter, the value field will be automatically filled in, and you can also inform the value manually or even not inform it, as needed. The data type used must be compatible with the param informed;
add parameter: add more parameters
result (read-only): here you will see the result of the created Expression
type (read-only): here you will see the data type of the displayed Result (string, number, Boolean, array or object). Note that the type you enter must match the type expected by the module/flow parameter
To add a parameter to the SMOP, select it from the available parameters. To do this, drag and drop it into the SMOP param1 field. Click "Add parameter" if you want to add another parameter.
You can use up to 3 original parameters within a SMOP.
Create a JSONata expression to perform the desired operation, using our template table. For example: param1 + param2
.
The Result and Type fields will display the corresponding information.
Click "Save" to finish. The operation field will now display the expression "SMOP", denoting that a SMOP operation has been set up:
To edit a SMOP:
Click on the down arrow sign next to the field with the SMOP you want to edit:
Make the necessary changes and click "Save".
There are two ways to delete a SMOP:
Click on the sign on the right-hand side of the SMOP.
Open the editing modal and click on "Delete".
expression (required): here you must enter the desired operation. All JSONata expressions are valid. In addition to using a parameter, as in the above, you can use functions like $now(), which require no parameters