Variables, JSON & expressions
Learn to save values, reuse API data, combine text, calculate numbers and create conditions without writing Python.
1. Ways to set a variable
In Script Editor, add set_variable. Put the output variable name in Target and the content in Value. Expressions must begin with =.
| Purpose | Target | Value |
|---|---|---|
| Plain text | name | PBX TECH |
| Copy another variable | copy | ${name} |
| Numeric value | count | = 100 |
| Text with a prefix | label | = "name: " + ${name} |
| Merge two variables | full_name | = ${first} + " " + ${last} |
| Math result | total | = ${price} * ${quantity} |
| Boolean comparison | eligible | = ${total} >= 500 |
2. Nested JSON objects and arrays
Suppose server_response contains this parsed JSON object (or a JSON string):
{"link":"https://example.com","user":{"name":"PBX"},"items":[{"id":101},{"id":102}]}
| Reference | Result |
|---|---|
${server_response.link} | https://example.com |
${server_response.user.name} | PBX |
${server_response.items.0.id} | 101 |
${server_response.items.1.id} | 102 |
Write a complete reference such as ${server_response.items} to preserve the JSON list when assigning it directly. References inside ordinary text are converted to display strings. You can still use json_get for explicit path extraction.
3. The calculate action
Add calculate under Script & Data. Target is the output variable, and Value is an expression beginning with =.
Action: calculate
Target: total
Value: = ${unit_price} * ${quantity}
Action: calculate
Target: greeting
Value: = "Hello, " + ${customer_name}
4. Math and text conversion rules
| Expression | Result | Type |
|---|---|---|
= 10 + 5 | 15 | Integer |
= 10 - 5 | 5 | Integer |
= 10 * 5 | 50 | Integer |
= 10 / 2 | 5 | Integer (exact) |
= 10 / 4 | 2.5 | Decimal |
= 10 + "abc" | 10abc | String |
= "abc" + 10 | abc10 | String |
= 10 - "abc" | 10 - abc | String |
= 10 * "abc" | 10 * abc | String |
= 10 / "abc" | 10 / abc | String |
When both operands are numbers, arithmetic remains numeric. When either operand is text, + joins strings; -, * and / produce readable strings rather than raising type errors. Numeric division by zero still produces an error.
5. Comparisons and conditions
Use these expressions in calculate, if, or else_if:
= ${amount} > 100
= ${amount} < 500
= ${status} == "completed"
= ${price} * ${quantity} >= 500
= ${amount} > 100 and ${quantity} < 10
= not (${status} == "failed")
Supported operators: +, -, *, /, >, <, >=, <=, ==, !=, and, or and not. Comparisons produce boolean values.
6. Complete example: API response to browser navigation
http_request
Target: https://your-authorized-api.example/items/1
Value: {"method":"GET","save_as":"server_response"}
set_variable
Target: destination
Value: ${server_response.link}
calculate
Target: display_name
Value: = "Destination: " + ${destination}
open_browser
Target: ${destination}Only open URLs you trust. Configure authentication and server access permissions separately.
7. Troubleshooting and limitations
"name: " + ${text} without the initial = stores ordinary text rather than evaluating the expression. Use quotes around literal strings inside expressions. Missing JSON keys or variables raise a clear error; numeric division by zero raises an error. Arbitrary Python functions, method calls and object mutation are not supported.Existing exact-name variables such as ${record.email} are still compatible. Development V41.8 expression changes have passed local tests but require full Windows workflow verification. The public release label remains v1.0.0.