Dynamic Flow Variable

The dynamic flow variable is a special type of variable that gets shared between actions.

When ever there is a need for passing the variable to another action then use this.

Name (optional JSON Path)

This specifies the name of the variable. It can be either a static name that you choose or a dynamic name based on the response of the current action or a previous action.

The "Behavior" field controls how this variable will behave, in conjunction with the "Name Property" field.

Value (optional JSON Path)

This specifies the value of the variable. It can be either a static name that you choose or a dynamic name based on the response of the current action or a previous action.

The "Behavior" field controls how this variable will behave

Behaviour

Set:

  • Description: Sets the value of a variable. If the same variable name is encountered again, the value will be overwritten.

  • Example: If you set MyVariable = A and then set it to MyVariable = B in the next action, the variable will have the value B.

Set foreach:

  • Description: Sets values for multiple variables based on a specified property. Useful for handling arrays.

  • Example: If you specify a JSON path to $.array with values [{prop:Lorum,next:n1},{prop:Ipsum,next:n2}] and set the Name Property field to prop, it results in:

    • Lorum = n1

    • Ipsum = n2

Append:

  • Description: Appends a value to an array in the variable's field. If the same variable is found again, the new value is appended.

  • Example: If you use MyVariable = A and in the next run set MyVariable = B, it will result in MyVariable = [A, B].

Append for each:

  • Description: Useful for collecting data when variables and values come from arrays. Appends values over each action.

  • Example: If variables come from [{prop:Lorum,next:n1},{prop:Ipsum,next:n2}] and values from $.id, the result with the Name Property field set to prop would be:

    • First run: Lorum = [123] and Ipsum = [123]

    • Next run with $.id = 456: Lorum = [123, 456] and Ipsum = [123, 456]

 

 

 

 

 

Example 1: Using Dynamic Flow Variables with a Fixed Name and SET:

Imagine you have a response from either the parent or the current action and want to set a variable. You could set up a Dynamic Flow Variable as follows:

Name: TheVariable

Value: $.path.to.value

Behavior: SET

In this case, the Dynamic Flow Variable TheVariable will take the value of $.path.to.value from the scope, overwriting the previous value if any. This is useful when you want to track only the latest value of a given response rather than accumulating values.

 

Example 2: Using Dynamic Flow Variables with JSON Path and APPEND:

Suppose you have a series of API calls in your workflow, and you want to accumulate a list of all the received responses in a variable called{" "} allResponses. You could set up a Dynamic Flow Variable as follows:

Name: allResponses

Value: {{ response.data } }

Behavior: APPEND

In this example, the Dynamic Flow Variable allResponses will gather the response bodies from each API call and append them to the existing value, creating a cumulative list.