Set State
  • 31 May 2023
  • 4 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Set State

  • Dark
    Light
  • PDF

Article Summary

The Set State node is exclusive to State Diagrams and is not available in processes.

This node was designed to store tasks and control their flow through a State Diagram. It allows you to keep a task within the node until a certain condition is met and then direct it to move to the next node associated with that condition (see Picture 1).

Set State.png

Picture 1. Task flow options in a Set State node

In State Diagrams, you have the flexibility to manipulate tasks from outside the diagram using the Modify Task node, API calls, or manually through View mode.

When a task is modified and it now meets one of the conditions specified, the task will proceed to the next node along that condition's corresponding edge. However, it's important to note that a modification does not necessarily have to trigger a node change. Instead, it can simply update the value of the task.

In a way, the Set State node in State Diagrams combines the functionality of the Condition and Waiting for Callback nodes found in processes.

Node Settings

Condition

The Set State node reacts to changes made to tasks from the outside. When the Set State node detects a change, it will run the task through the set of conditions listed within the node, top to bottom, and if a condition is met, the task will follow that condition’s outgoing edge. If no condition is met, the task stays in the node.

The interface of this part of the node is identical to that of the Condition node. See Condition node documentation for a more detailed explanation.

Key, Value : The pair of parameters whose values will be compared. The key is typically used for specifying variables, and the value is usually used for specifying static values. To use a variable in the value field put {{}} double curly braces around it.

The following comparison operators are available:

== 
!= 
> 
< 
RegExp 
Set State can have no conditions

Unlike the Condition node, Set State does not have to include a condition. If it does not have a condition, the tasks will stay in it forever.

Other

Alert if the number of tasks in the node queue reaches the following number - a condition that will be met when the node has a specified number of tasks in it. If this option is selected, a new edge will be created.

Maximum interval, for which the task stays in the node before being forwarded - the amount of time a task must spend in this node. Can be specified in seconds, minutes, hours, or days.

Examples

Storage

You can safely store any values you might need to run your processes, such as login and password, within the Set State node. Simply create a state diagram with a single Set state node and add tasks with sensitive parameters there. This way, you can simply reference them when you need to use them in your other processes, without revealing their actual value (see Picture 2).

image.png

Picture 2. Storing sensitive parameters in a Set State node to be able to reference them in other processes without revealing them

Reacting to changes in task parameters

The purpose of this example is to demonstrate how the Set State node behaves in response to receiving tasks, and tasks being modified within it. We will show that the conditions set within the node are not checked when the node first receives the task, and are only checked when a task is modified.

We created a Set State node that includes a condition Status == Inactive. If this condition is met, the task is sent to another Set State node.

Case 1: Condition is not satisfied

We create a task with the parameter Status having the value Aсtive.
When we add this task, it stops in our Set State node.

We then modify the task to have Status = Inactive. Once we do that, our Set State node goes over the set conditions, determines that it is met, and the task is passed to the next node (see Picture 3).

Set state 1.gif

Picture 3. Example of a task proceeding through a Set State node when a specified condition is not met

Case 2: Condition is satisfied

We create a task with the parameter Status having the value Inactive. When we add this task, it stops in the first Set State node, even though the condition within it is met.

We now "modify" the task by simply calling the Modify command on it, but not changing anything. Only now our task is passed to the next node (see Picture 4).

Set State 2.gif

Picture 4. Example of a task proceeding through a Set State node when a specified condition is met

Error handling & troubleshooting

When an error occurs in the node, the following fields are added to the initial task depending on the error and node type:

Error parameter nameParameter description
__conveyor_node_type_return_type_error__Error type: hardware (system error), software (error in a node logic/settings)
__conveyor_node_type_return_type_tag__Error tag
__conveyor_node_type_return_type_description__Error description in human-readable language. Can be static or dynamic
ProblemCauseSolution
Task is not being updated.If the task has an empty reference, it cannot be updated. An empty reference is not considered to be unique.Update the task reference manually.

What's Next