Assign action in Dictionary
- Updated: 2023/07/03
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.
- 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: Dictionay_Assign.
- 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.
- 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
- Create two variables of Dictionary
type:
- To assign the value of the source dictionary to the destination
dictionary variable, double-click or drag the action.
- Select the source dictionary variable from the drop-down list or create and enter AppraisalData_FY22 in the Select the source dictionary variable field.
- 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. - 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"}$
- Click Save and then
Run.
The output is displayed as:
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.