Exercise - Use message boxes to communicate
In attended automation, the interaction between users and workstations is essential. Message boxes provide a direct means for this communication to take place.
In this exercise, you develop an attended flow that reads orders from Excel worksheets and prompts users to select a discount for high-value orders.
To begin, download Orders.zip. Select Download on the right and extract the Excel file to your local computer.
Start by prompting the user to select an Excel file. Use the Display select file dialog action and configure the File filter field to allow only xlsx files.
Before reading any data from the selected file, you have to launch it using the Launch Excel action.
To read the data from the Excel file, deploy the Read from Excel worksheet action and select All available values from worksheet in the Retrieve field.
Open the Advanced properties and turn on First line of range contains column names.
Deploy the Get first free column/row from Excel worksheet action to retrieve the first free column and row in the Excel worksheet.
Use the Write to Excel worksheet action to add a Discount header in the first free column of the Excel file.
Before handling each Excel row independently, create a new variable named Counter and initialize it to 2. This variable indicates the number of the row you're handling in each iteration.
Add a For each loop to iterate through the retrieved data.
To check the value of the Gross column (column G or the sixth column in the worksheet), convert it into a number, and then add an If action to check whether it exceeds 100,000.
If the value exceeds 100,000, the user should decide whether to add a discount. Deploy the Display message action to provide the necessary information to the user, and prompt them to choose Yes or No.
Add a second If action to check which button was pressed in the previous step.
If the user selects Yes, a window prompts them to enter the discount amount; use the Display input dialog action to achieve this functionality.
Write the selected discount amount into the Discount column of the Excel file.
Before exiting the previously created For each loop, use the Increase variable action to increase the Counter variable by one.
Finally, run the flow. When prompted, select the Orders.xlsx file.