Example of using Custom selection option in Log variables to file action

In this example, you will use the Custom selection option to log user-defined variables to an existing log file and then modify the values of the variables and log the appended data into a file.

Procedure

  1. Create a bot.
    1. On the left panel, click Automation.
      A list of available bots and forms is displayed.
    2. Click Create New > Task Bot.
    3. Enter a name for the bot: Log user defined variables
    4. Click Create and Edit.
  2. Create the following user-defined variables using the Create variable (+) icon at the top of the Variables menu.
    Data type Variable name Variable value
    String Day_1 monday
    String Day_2 Tuesday
    String Day_3 Wednesday
    Number Temperature_Mon 9.3555555555555589
    Number Temperature_Tues 10.82222222222222
    Number Temperature_Wed 17.800000000000004
    Datetime Time_Mon 5/7/2023 01:15 AM
    Datetime Time_Tues 5/8/2023 01:00 AM
    Datetime Time_Wed 5/9/2023 01:00 AM
    Boolean Chances_of_rain_Mon True
    Boolean Chances_of_rain_Tues False
    Boolean Chances_of_rain_Wed True
  3. Double-click or drag the Log to file > Log variables to file action.
    1. In the Output file path field, specify the file location. For example, D:\userdefined path\weather_forecast-data.txt.
    2. In the When logging field, select Overwrite existing log file option.
    3. In the Variables to log field, select the Custom selection option and select all variables as follows:
    choose custom option to log variables
  4. Click Save and then Run.
    The data is logged as follows:

    Log data to a file

  5. Double-click or drag the String > Uppercase action.
    1. In the Source string field, select Day_1 to insert the variable.
    2. In the Assign the output to variable field, select the Day_1 variable from the drop-down.
  6. Double-click or drag the Number > Increment action.
    1. In the Enter number field, select Temperature_Tues to insert the variable.
    2. Enter 15 in the Enter increment value field.
    3. In the Assign the output to variable field, select Temperature_Tues variable from the drop-down.
  7. Double-click or drag the Boolean > Invert action.
    1. From the Select the boolean variable to be inserted field, select the True option.
    2. In the Assign the output to field, select the Chances_of_rain_Wed variable from the drop-down.
  8. Double-click or drag the Log to file > Log variables to file action.
    1. In the Output file path field, specify the file location. For example, D:\userdefined path\weather_forecast-data.txt.
    2. In the When logging field, select Append to existing log file option.
    3. Select the Append timestamp check box.
    4. In the Variables to log field, select the Custom selection option and select all variables as previously shown in Step 3c.
  9. Click Save and then Run.
    The updated data is logged with the timestamp details in the file as follows.

    Log the appended data