Assign action in Dictionary

You can use the Assign action in the Dictionary package to assign the value of a source dictionary to the destination dictionary variable.

Example of assigning a source dictionary value

This example shows you how to create a bot that assigns the source dictionary value to the destination dictionary variable.

  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: Dictionay_Assign.
    4. Click Create and Edit.
  2. Create the user-defined variables using the Create variable (+) icon at the top of the Variables menu.
    • Create two variables of Dictionary type:
      • Source dictionary variables: AppraisalData_FY22
      • Destination dictionary variable: AppraisalData_FY23
    • Enter the following key-pair values in the source and destination dictionary variables.

      AppraisalData_FY22 (Source)

      Key Value
      Name Bob, John, Sarah
      Age 52, 26, 42
      Job title Sr. Developer, Technical Writer, HR
      Email ID bob.jones@abc.com, john@abc.com, sarah@abc.com
      Phone number 752000000, 753000000, 754000000
      CTC $160,000, $110,000, $100,000
      Bonus component Sr. Developer: 15%, Technical Writer: 15%, HR: 15%
      Employment type Sr. Developer: Permanent, Technical Writer: Contractor, HR: Permanent

      AppraisalData_FY23 (Destination)

      Key Value
      Name Bob, John, Sarah
      Age 52, 26, 42
      Job title Sr. Developer, Technical Writer, HR
      Email ID bob.jones@abc.com, john@abc.com, sarah@abc.com
      Phone number 752000000, 753000000, 754000000
      CTC $170,000, $120,000, $110,000
  3. To assign the value of the source dictionary to the destination dictionary variable, double-click or drag the Dictionary > Assign action.
    1. Select the source dictionary variable from the drop-down list or create and enter AppraisalData_FY22 in the Select the source dictionary variable field.
    2. To hold the output, select a variable or create and enter AppraisalData_FY23 in the Select the destination dictionary variable field.
    Note: If both (source and destination) dictionary variables contain the same keys, the destination dictionary variable will be overwritten by the value of the source dictionary variable.
  4. To print the value of the destination variable (AppraisalData_FY23), double-click or drag the Message box action. Enter the following values in the Enter the message to display field:
    • $AppraisalData_FY23{"Job tile"}$
    • $AppraisalData_FY23{"CTC"}$
    • $AppraisalData_FY23{"Bonus component"}$
    • $AppraisalData_FY23{"Employment type"}$
  5. Click Save and then Run.

    The output is displayed as:

    values assigned to the destination dictionary variable

    The output shows that the key and its values (Bonus and Employment type) in the source variable (AppraisalData_FY22) are assigned to the destination variable (AppraisalData_FY23) . Additionally, the source and destination variables contain the same keys for CTC. As a result, the value in the destination dictionary variable is overwritten by the value of the source dictionary variable.