Example of using the Assign action
- Updated: 2024/07/30
Example of using the Assign action
In this example, you will create an automation to store the current date and time in a variable, calculate a future date by adding a specified number of days, and log the variables in a file for verification.
Procedure
- Create an automation.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: Datetime-assign.
- Click Create and Edit.
- On the left panel, click Automation.
- Create the following user-defined variables using the Create
variable (+) icon at the top of the
Variables menu.
Variable name Variable type Default value Currentdate Datetime - Futuredate Datetime - - Double-click or drag the Assign action from the Datetime package in the Actions palette.
- From the Select the source datetime variable/ value, choose the Variable option.
- From the Variable tab, choose Variable and enter
$System:Date$.Note: You can use the System: Date variable to get the current date. In this example, the System: Date value is considered as 7/22/2024 07:00 AM IST (UTC+5:30) Calcutta, Asia
- In the Select the destination datetime variable field, select the Currentdate variable to store the system date.
- Double-click or drag the Add action from the Datetime package in the Actions palette.
- In the Source date and time variable field, choose the Variable option.
- In the Variable field, enter $Currentdate$.
- In the Time value to add field, enter the value 7.
- In the Time unit to add field, select Days.
- In the Assign the output to a variable field, select the Futuredate variable to store the output.
- Log the current and future dates for verification.
- Double-click or drag the Log variables to file action from the Log To File package in the Actions palette.
- In the Output file path field, enter
C:\Bot testing\logtofile.txt.Note: If a .txt file is not already available, create a new one.
- From the Variables to log field, choose Custom selection.
- Select the variables Currentdate and Futuredate.
- Click Save and then Run.
The bot logs the variables in the .txt file and displays the variables as follows: