Evaluate an expression on some data and write the result to a data area or attribute.
This step type can be used in many scenario, such as:
- Branching logic in a flow. In this case, use the expression to calculate a state, and then write this to the state attribute.
- Transform or combine data structures.
Parameters can be passed in data or in config.
Input data for the evaluation.
This would typically be a reference to an attribute or data area using runtime placeholders.
If you want multiple inputs, pass in an object with multiple placeholders. For example, for an expression that needs to look at both the "template" and "response" data areas, you might code
|dataReference||Data area to which results should be written. If not given, results are not written to a data area.|
Attribute to which results should be written. If not given, results are not written to an attribute.
Use "attributeReference":"state" to output to the state attribute used for flow control.
Script to evaluate the data.
This can access the input data as variable data.
Simple scripts be entered on a single line, as in this example which looks at some previously set form data, and sets the "state" attribute to reflect whether the confirmed property was set.
More complex evaluation will require more complex scripts. These can be passed in in various ways: read from data areas, or read from scripts using the process compiler. More complex scripts can be wrapped in anonymous functions, like the example below which is equivalent to the one-liner above.
Scripts may return objects or arrays, not just single values.
Scripts have no access to the application object or to any data other than the passed-in data.
The script can be passed as an array of lines, which will be concatenated with new lines in between. This can be useful when including "library" code.
Script exception will give runtime errors in the process. Error conditions should be signalled by returning error value of some type.
The script defaults to "null", which returns null. To return the data itself, set the script to "data".
Results of the evaluate are returned as the return value from the script (in the <return> element of the response, as usual).
The evaluate step also supports the remote, permit and removeRequest config parameters.
Member Type List