Wiki source code of SetVar
Version 3.3 by Outhman Moustaghfir on 2024/01/30 15:03
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | = SetVar Connector Documentation = |
2 | |||
3 | == Overview == | ||
4 | |||
![]() |
3.2 | 5 | [[image:setvar.png]] |
6 | |||
![]() |
1.1 | 7 | 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. |
8 | |||
9 | == Usage == | ||
10 | |||
11 | === JSON Format === | ||
12 | |||
![]() |
3.2 | 13 | [[image:Capture d'écran 2024-01-30 150237.png]] |
14 | |||
![]() |
1.1 | 15 | 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. |
16 | |||
17 | ==== Example 1: ==== | ||
18 | |||
19 | {{{ | ||
20 | }}} | ||
21 | |||
![]() |
3.3 | 22 | {{code language="json"}} |
23 | { "var1": "value1", "var2": "true" } | ||
![]() |
1.1 | 24 | |
25 | {{/code}} | ||
26 | |||
27 | |||
28 | ==== Example 2: ==== | ||
29 | |||
30 | {{{ | ||
31 | }}} | ||
32 | |||
33 | {{code language="XML"}} | ||
34 | SetVar(variable_name, value, global=False) | ||
35 | |||
36 | {{/code}} | ||
37 | |||
38 | { "var1": "value1", "var2": "true", "inputFile1": "${GetVar;inputFile}", "nestedVar": { "nestedVar1": "val1", "nestedVar2": "val2" } } | ||
39 | |||
40 | === Dynamic Values === | ||
41 | |||
42 | SetVar supports dynamic values using expressions in the ${GetVar;variableName} format. This allows you to reference the values of other variables within the JSON file. | ||
43 | |||
44 | == Examples == | ||
45 | |||
46 | === Setting Basic Variables === | ||
47 | |||
48 | {{{ | ||
49 | }}} | ||
50 | |||
51 | {{code language="json"}} | ||
52 | { "username": "john_doe", "email": "john.doe@example.com", "isAdmin": "false" } | ||
53 | {{/code}} | ||
54 | |||
55 | |||
56 | === Using Dynamic Values === | ||
57 | |||
58 | |||
59 | {{code language="json"}} | ||
60 | { "var1": "value1", "var2": "${GetVar;inputFile}", "nestedVar": { "nestedVar1": "val1", "nestedVar2": "val2" } } | ||
61 | {{/code}} | ||
62 | |||
63 | |||
64 | == Important Notes == | ||
65 | |||
66 | * Variables set by SetVar can be referenced within the same JSON file or in subsequent scenarios. | ||
67 | * Ensure proper syntax for dynamic values using ${GetVar;variableName}. | ||
68 | |||
69 | == Conclusion == | ||
70 | |||
71 | 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. |