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

  1. Create an automation.
    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: Datetime-assign.
    4. Click Create and Edit.
  2. 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 -
  3. Double-click or drag the Assign action from the Datetime package in the Actions palette.
  4. From the Select the source datetime variable/ value, choose the Variable option.
  5. 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
  6. In the Select the destination datetime variable field, select the Currentdate variable to store the system date.
  7. Double-click or drag the Add action from the Datetime package in the Actions palette.
  8. In the Source date and time variable field, choose the Variable option.
  9. In the Variable field, enter $Currentdate$.
  10. In the Time value to add field, enter the value 7.
  11. In the Time unit to add field, select Days.
  12. In the Assign the output to a variable field, select the Futuredate variable to store the output.
  13. Log the current and future dates for verification.
    1. Double-click or drag the Log variables to file action from the Log To File package in the Actions palette.
    2. 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.
    3. From the Variables to log field, choose Custom selection.
    4. Select the variables Currentdate and Futuredate.
  14. Click Save and then Run.

    The bot logs the variables in the .txt file and displays the variables as follows:

    Currentdate and Futuredate variables logged in the .txt file