Recursive expressions
- Updated: 2025/03/21
Use a recursive expression to insert a variable in the place of an index or key of a dictionary, list, record, or table variable.
A recursive expression contains a variable nested inside of another variable (the outer variable). The value of the outer variable is conditional based on the value of the nested variable.
For example, the list variable $listOfPlanets$
has the following
values: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune. The
Number variable $indexPosition$
has value of 2. The expression
$listOfPlanets[$indexPosition$]$
returns
Earth
.
- $dictionaryVariable{$key$}$
- $listVariable[$index$]$
- $recordVariable[$index$]$
- $tableVariable[$rowIndex$][$columnIndexOrName$]$
- You cannot use a Table variable within a List variable. For example, the
following expression is not supported:
$vListStr[$vTable[0][0]$]
- You cannot combine expressions with properties. For example, the following
expression is not supported:
$dictionaryVar{$listStrVar[2]$}.String:reverse$
Example
This nested dictionary example illustrates an organizational structure. The dictionary contains employees with hierarchical roles and subordinates.
- Create a bot.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: Recursive Expression.
- Click Create and Edit.
- On the left panel, click Automation.
- Create the user-defined variables using the Create
variable (+) icon at the top of the
Variables menu.
- Double-click or drag the Message box
action. Perform the following steps to retrieve the value of
Department 1 from Org_Dept.
- Press F2 or click (x) icon to insert a value in the Enter the message to display field.
- In the Insert a value window, choose the variable Org_Dept.
- Click Add expression item. Select By name tab and enter the value Department 1.
- Click Insert to add the following expression $Org_Dept{"Department 1"}$ in the Enter the message to display field.
- Double-click or drag the Message box
action. Perform the following steps to retrieve the value of
Engineering from Org_Roles.
- Press F2 or click (x) icon to insert a value in the Enter the message to display field.
- In the Insert a value window, choose the variable Org_Roles from the list.
- Click Add expression item. Select By name tab and click (x) to insert a value.
- In the Insert a value window, choose the variable Org_Dept.
- Click Add expression item. Select By name tab and enter the value Department 1.
- Click Insert to add the nested expression $Org_Dept{"Department 1"}$.
- Click Insert to add the following expression $Org_Roles{$Org_Dept{"Department 1"}$}$ in the Enter the message to display field.
- Repeat Step 4 to create the following nested expression $Org_Reportee{$Org_Roles{$Org_Dept{"Department 1"}$}$}$ to retrieve the value of Dev Manager from Org_Reportee.
- Repeat Step 4 to create the following nested expression $Org_Structure{$Org_Reportee{$Org_Roles{$Org_Dept{"Department 1"}$}$}$}$ to retrieve the value of CTO from Org_Structure.
- Click Save and then Run.The output is displayed as:
The nested dictionary retrieves the value of Department 1, which is Engineering. The Engineering department has a Dev Manager as a role. The Dev Manager reports to the CTO, and the CTO reports to the CEO, the head of the Organization.