Wiki source code of SetVar

Last modified by Outhman Moustaghfir on 2024/09/27 13:43

Show last authors
1 = SetVar Connector Documentation =
2
3 == Overview ==
4
5 [[image:setvar.png]]
6
7
8 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.
9
10 == Usage ==
11
12 === JSON Format ===
13
14 [[image:1727437198067-371.png]]
15
16
17 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.
18
19 ==== Example 1: ====
20
21 {{{
22 }}}
23
24 {{code language="json"}}
25 { "var1": "value1", "var2": "value2" }
26
27 {{/code}}
28
29
30 ==== Example 2: ====
31
32 {{{
33 }}}
34
35 {{code language="json"}}
36 { "var1": "value1", "var2": "{Env.GetVar;variableName}" }
37 {{/code}}
38
39 == Global Values ==
40
41 SetVar supports dynamic values using XGlobal before the variable name to make this var accessibel in the parent sceanrio .
42
43 == Examples ==
44
45
46 {{code language="json"}}
47 { "iXGlobal:Key": "Value" }
48 {{/code}}
49
50 === Dynamic Values ===
51
52 SetVar supports globalvalues using iXPath functions (GetVar, Date, GetTracking...). This allows you to reference the values of other variables within the JSON file.
53
54 == Examples ==
55
56 === Setting Basic Variables ===
57
58 {{{
59 }}}
60
61 {{code language="json"}}
62 { "username": "john_doe", "email": "john.doe@example.com", "isAdmin": "false" }
63 {{/code}}
64
65
66 === Using Dynamic Values by GetVar function ===
67
68
69 {{code language="json"}}
70 { "username": "john_doe", "email": "{Env.GetVar;Email}", "isAdmin": "false"}
71 {{/code}}
72
73
74 == Important Notes ==
75
76 * Variables set by SetVar can be referenced within the same JSON file or in subsequent scenarios.
77 * Ensure proper syntax for dynamic values using **iXPath functions**.
78 * We can define variables using either a JSON file or by entering values in the content text area.
79
80 == Conclusion ==
81
82 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.
This wiki is hosted and managed by iXPath
Powered by XWiki 13.3 debian