Modify a basic bot to process dynamic data
You can modify a TaskBot so it can dynamically process data from a CSV file to complete a web page automation. Reading a CSV file is an example of processing dynamic data. Bots can read files from CSV, text, Microsoft Excel, PDF, SQL database, web pages, and more.
John,Doe,Example LLC,firstname.lastname@example.org,123-123-1234,john.doe,sample0domain Karen,Smith,Example LLC,email@example.com,123-321-7654,ksmith,domain123 Mike,Lee,Example LLC,firstname.lastname@example.org,123-456-7890,mike-lee,domainsample
This task is to understanding the basic bot design. Regardless of which recorder was used, a recorded task is not a complete process. Recorders are a great first step, but bot developers must add business logic and edit recorded commands to ensure proper playback by the Bot Runner.
- Create a loop for processing each row in a CSV file.
- Make each step accept input from a CSV file and write output to the web form.
To make the basic TaskBot accept data from a CSV file, perform these steps:
- Open the Automation Anywhere Enterprise Client.
Double-click the task to open it in the Workbench, or right-click and select Edit.The TaskBot opens in the Workbench. Each line in the Actions List represents one step that was captured by the Web Recorder.
- Click on line 2 in the Actions List and select it.
- In the Commands tab on the left, drag the Read From CSV/Text command and drag in the top of line 2 in the Actions List.
- In the Read From CSV/Text window, click the ellipsis button at the end of the Select File field.
- Locate and select the names.csv file that you created as part of the prerequisites.
- Click Open.
The system also adds the Start Loop and End Loop commands in the Actions List. The green line is a comment added by Automation Anywhere. The comment in the Actions List indicates which system variable gets the information from the file.
- Drag the End Loop command to the bottom of the Actions List.
Modify each of the
Set text $Filedata Colums$steps to assign a variable to
- Double-click line 6 after the Comment.
- In the Web Recorder window, click Advanced View.
- Clear the Text to set field.
- Press the F2 key to open the Insert Variable dialog box.
- Scroll down to the Filedata Column, select it, and click Insert.
- In the window that opens, clear the Column Number / Select Variable field and type 1.
- Click OK.
Repeat steps a through h for lines 7 to line 12. Ensure that you enter the appropriate column number for each line.Note: Each line in the names.csv file is equivalent to a step or row. Each step has seven columns, for example:
- Column 1 =
- Column 2 =
- Column 3 =
- Column 4 =
- Column 5 =
- Column 6 =
- Column 7 =
- Column 1 =
- At the top of the Workbench window, click Save.
- Click Run to test the bot.