Set Variable Node in Pathways

From FojiSoft Docs
Revision as of 23:10, 5 March 2025 by Mitchell.Hirsche (talk | contribs) (Mitchell.Hirsche moved page Documentation: Set Variable Node in Pathways to Set Variable Node in Pathways)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Set Variable node is used to define or modify variables within a Pathways workflow by using expressions.

Configuration Options:

  1. Name:
    • Provide a unique name for the node to identify it in the workflow.
  2. Variable Name:
    • Specify the name of the variable you wish to set or modify.
  3. Expression:
    • Enter the expression to calculate or assign the value to the variable.
    • You can select the Type for the expression:
      • Script: Use custom scripting for advanced logic.
      • Handlebars Template: Use templating for dynamic content generation.
  4. Object Handling:
    • Choose how the variable should handle object data:
      • Replace: Overwrite the existing object with the new value.
      • Merge Values: Merge the new data with the existing object, combining their properties.

Usage Example:

Set a variable totalPrice using a Handlebars Template to calculate the value dynamically:

{{product.price * product.quantity}}

Use the Script option for more complex logic:

if (customer.isPremium) {

 totalPrice = basePrice * 0.9; // Apply discount

} else {

 totalPrice = basePrice;

}

Notes:

  • This node is essential for creating dynamic workflows where variable values change based on user input, external data, or logical conditions.
  • Combining the "Set Variable" node with other nodes like If, Parallel, and Loops allows for greater control over workflow logic.

By utilizing this node effectively, you can create workflows that are both dynamic and adaptable to various scenarios.