Scenario - SetVar 

Page / - last modified by Outhman Moustaghfir on 2024/03/11 17:14 

SetVar 
last modified by Outhman Moustaghfir
on 2024/03/11 17:14

Table of Contents
SetVar Connector Documentation
Overview
Usage
JSON Format
Global Values
Examples
Dynamic Values
Examples
Setting Basic Variables
Using Dynamic Values by GetVar function
Important Notes
Conclusion

SetVar Connector Documentation
Overview

The SetVar connector is designed to set variables within a scenario by utilizing a JSON file. This connector allows users to define variables and even use dynamic values using expressions.
Usage
JSON Format

The JSON file for SetVar has a simple structure. It consists of key-value pairs, where the keys represent variable names, and the values can be either static values or dynamic expressions.
Example 1:
 
{ "var1": "value1", "var2": "value2" }
Example 2:
 
{ "var1": "value1", "var2": "{Env.GetVar;variableName}" }
Global Values
SetVar supports dynamic values using XGlobal before the variable name to make this var accessibel in the parent sceanrio .
Examples
{ "iXGlobal:Key": "Value" }
Dynamic Values
SetVar supports globalvalues using iXPath functions (GetVar, Date, GetTracking...). This allows you to reference the values of other variables within the JSON file.
Examples
Setting Basic Variables
 
{ "username": "john_doe", "email": "john.doe@example.com", "isAdmin": "false" }
Using Dynamic Values by GetVar function
{ "username": "john_doe", "email": "{Env.GetVar;Email}", "isAdmin": "false"}
Important Notes
•	Variables set by SetVar can be referenced within the same JSON file or in subsequent scenarios.
•	Ensure proper syntax for dynamic values using iXPath functions.
•	We can define variables using either a JSON file or by entering values in the content text area.
Conclusion
The SetVar connector simplifies the process of setting and managing variables within your scenarios. By providing both static and dynamic values, it offers flexibility and enhances the reusability of variable values across different parts of your workflow.