Use the Conditional Threshold block in workflows when you want actions to be completed when the threshold is reached and when the threshold isn't reached.
Creating the workflow
- From the menu, click Configuration > Workflows.
- Click Add (+).
- Select a module, for example, Assets.
- Enter the name and a description of the workflow.
Editing the Begin block
Specify the criteria needed to trigger the workflow in the Begin block.
- Edit the Begin block
- Add rules to trigger the workflow, for example:
- The Actions dropdown is set to Schedule
- The Manufacturer field is not Empty
- Click Save.
Adding the Conditional Threshold block
- Click Blocks, and drag and drop the Conditional Threshold block onto the canvas.
- Click Edit.
Basic Mode
The Conditional Threshold block opens in Basic Mode.
In Basic Mode you can do the following:
- Enter a meaningful name for the block.
- Select a field to compare against, such as Manufacturer
- Select an Operator such as Equals.
- From the Compare to list, select Field or Value
- If you selected Field, enter the field you wish to compare it against.
- If you selected Value, enter the threshold Value in text format. This field does not support Jinja syntax.
- Click SAVE.
If you wish to specify multiple conditions or create a more complex query, click Advanced Mode.
Advanced Mode
In Advanced Mode you can enter a logical expression using Jinja syntax. When entering your logical expression make sure that it appears on one line.
➢ Use the Assistant
You can ask the assistant for help generating Jinja code. For example, you may wish to ask:
- Check if a field starts with a value.
- Check if a field is within a certain range.
- Check for the presence of a certain character.
- Check the length of a field.
- Check if a field matches a predefined list.
Using the Assistant to generate Jinja code
➢ Input variables
Manually enter the name of the field into the editor or click Select a field to retrieve field values. You can access the following field values:
- Data Model fields as
{{barcode}}or{{email}} - Values from global settings
- Workflow variables
➢ Test your Jinja code
- Click Test Run.
- Input a sample value to test your code.
- The output should automatically generate.
Important
You cannot switch from Advanced Mode to Basic Mode once you have entered a Jinja expression.
Examples
{% if manufacturer.startswith('App') %} True {% else %} False {% endif %}
{% if barcode == "LX008888" %}True{% else %}False{% endif %}
{% if barcode|length > 1 %}True{% else %}False{% endif %}
{% if barcode|length > 1 or barcode == "LX008888" %}True{% else %}False{% endif %}
{% if barcode.endswith("8") %}True{% else %}False{% endif %}
Connecting the block
Add another block onto the canvas that will run if the condition is True. In the example below, an update block is added to update the barcode starting with "LX".
- Click Blocks, and drag and drop the Update block onto the canvas.
- Click Edit.
- Click Add field and select the Barcode field from the list.
- Enter a value or Jinja syntax.
- Click Save.
Launching the workflow
- Connect the blocks.
- Validate the workflow and Activate it, so that the workflow is live in your system.
- Click Run Scheduled Workflow
- Click Run Logs
.
- Your workflow should appear in the latest run log. If the logical expression used is invalid, the conditional threshold block fails with the error: Unable to execute provided logical expressions. Follow the tips and examples above to update your expression.
- When your workflow is successful, navigate to a record. In the example below, the Apple devices that have barcodes starting with "LX" are updated as per the conditions met in the Conditional Threshold and Update block.
Documentation
Using Jinja operations in workflows
Comments
0 comments
Please sign in to leave a comment.