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.

The following types of expressions are supported. You can create a recursive expression containing up to 10 expressions.
  • $dictionaryVariable{$key$}$
  • $listVariable[$index$]$
  • $recordVariable[$index$]$
  • $tableVariable[$rowIndex$][$columnIndexOrName$]$
Note:
  • 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 the following variables:
  1. Create a bot.
    1. On the left panel, click Automation.

      A list of available bots and forms is displayed.

    2. Click Create a bot.
    3. Enter the bot name: Recursive Expression.
    4. Click Create and Edit.
  2. Create the user-defined variables using the Create variable (+) icon at the top of the Variables menu.
    Variable name Type Subtype Default values
    Org_Dept Dictionary String
    • Key: Department 1 :: Value : Engineering
    • Key: Department 2 :: Value : Finance
    • Key: Department 3 :: Value : Product
    Org_Roles Dictionary String
    • Key: Engineering :: Value : Dev Manager
    • Key: Finance :: Value : Finanancial analyst
    • Key: Product :: Value : Product Manager
    Org_Reportee Dictionary String
    • Key: Dev Manager :: Value : CTO
    • Key: Finanancial analyst :: Value : CFO
    • Key: Product Manager :: Value : CPO
    Org_Structure Dictionary String
    • Key: CTO :: Value : CEO
    • Key: CFO :: Value : CEO
    • Key: CPO :: Value : CEO
  3. 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.
  4. 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.
  5. 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.

  6. 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.

  7. Click Save and then Run.
    The output is displayed as:
    Variable expression Output
    $Org_Dept{"Department 1"}$ Engineering
    $Org_Roles{$Org_Dept{"Department 1"}$}$ Dev Manager
    $Org_Reportee{$Org_Roles{$Org_Dept{"Department 1"}$}$}$ CTO
    $Org_Structure{$Org_Reportee{$Org_Roles{$Org_Dept{"Department 1"}$}$}$}$ CEO

    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.