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.

Automation 360

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 Source date and time variable field, choose either of the following options:
    • Enter the date and time: You can enter the date and time manually by choosing any of the following:
      1. Select a suitable format from the Prebuilt formats list. Enter the date and time in the exact same format. For example: If you choose ISO_LOCAL_DATE_TIME ('2011-12-03T10:15:30'), ensure the date-time is in the format 2011-12-03T10:15:30.
      2. Provide a custom format through any of the following date pattern letters:
        • yyyy is the four-digit year, yy is the two-digit year
        • MM is the month number, MMM is the short month name (Jul), MMMM is the full name (July)
        • dd is the day of the month
        • HH is the hour in 24-hour time, hh is the hour in 12-hour time
        • mm is minutes, ss is seconds
        • a is AM/PM
        • z or Z is the time zone
        Note that the letters are case sensitive. MM means month but mm means minutes, and HH (24-hour) differs from hh (12-hour). For example, to enter the date as 07/22/2024 07:00 AM, provide the Custom Formats as MM/dd/yyyy hh:mm a.
    • Variable: Give a name to the variable.
      • 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.
  10. Log the current and future dates for verification.
    1. Double-click or drag the Log variables to file action from the Logging 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.
  11. 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