BACK

v11 Tutorial: Data Extraction and Currency Conversion

Prerequisites

You’ll need to have Automation Anywhere Enterprise v11 workbench installed and licensed with a bot creator license to follow along with this lab.

Background

Our fake company has received several invoices from foreign companies. As such, the invoices are all in GBP instead of USD. In this lab, we’ll create a bot to read each line from an HTML table to extract out the invoice amount in GBP as well as the invoice date. We’ll then need to use a Bot Store currency conversion app to convert the extracted GBP to USD based on the conversion rate when the invoice was received. Extract the data for all 5 invoices, convert them to USD, and submit to complete the exercise.

Pseudocode

Let’s start with our pseudocode again. Remember, think of pseudocode as the human readable steps that our bot will need to accomplish. To get started thinking about the steps we’d need to take – look at the exercise page to understand the specifics of this exercise.

Step 1: Launch Website – We’ll have to have the website open before we can start extracting or entering data.
Step 2: Loop Through HTML Table Rows – There are 5 rows of invoices we want to extract, so we’ll need to be able to interact with them all without having to write 5x the code.
Step 3: Extract Invoice Amount and Date – We’ll be reading the values from 2 different columns in the table for the currency conversion.
Step 4: Convert Currency via Bot Store Bot – We’ll leverage a pre-built Bot Store bot to help us with the back dated currency conversion.
Step 5: Enter Converted Currency in Web App – Once the converted currency comes back from the Bot Store bot, we’ll need to fill it into a web form field for each row.
Step 6: Repeat for All Rows – The extraction, conversion, and data entry will have to happen once for each row. We’ll discuss using a concept of repetition to prevent us from writing 5x the code.
Step 7: Click Submit – Press the Submit button once our bot done entering data for each row.

Building the Bot

We have a good start on our requirements, and we understand what needs to happen for this exercise to be completed successfully. We’ll be building from scratch on this one, so we’ll need to create brand new bot.

  1. Launch and login to the Automation Anywhere Client (Either Enterprise or Community – either will work).
  2. In the upper left corner of the screen, click the “New” button.
  3. An “Automate” dialogue will appear asking how you want to get started. Press the Workbench button to continue.
  4. A blank Workbench session will open. Before we get started adding commands to our Actions List, we’ll need to create some variables to store some of our data for this exercise. Variables are used to label and store data that our bot uses for processing.
    1. In Automation Anywhere, the best practice is to prefix custom variables with a lower-case v then use camel case naming with no spaces for the rest of the variable name.
  5. Before we start creating our variables, it’s important to understand what variables we need to create, what to call them, and why we would need them in the first place. On the exercise page for this lab (INSERT URL THERE) – review the fields that we mentioned we might need in our psuedocode. We’ll add some more variables once we review what’s required from the Bot Store bot, but for now, review what we should need from the exercise page.
  6. To create our first variable, click on the Variable Manager tab on the far-right side of your Workbench window. Clicking this tab will expand the Variable Manager tab.
  7. We’ll be creating a few variables for this exercise. Instead of going through and creating them all together, we’ll document how to do one, then show a table for the rest.
  8. With the variable manager tab expanded, click the Add button to add a new Variable. An Add Variable dialogue will appear.
    1. In the Add Variable dialogue, enter vInvoiceDate into the Name field leaving the Variable Type as Value and the Select dropdown as Value.
    2. We’re going to leave the variables we create blank for now, because we’ll let the bot take care of assigning the variables a value.
    3. Press the Save button to save your newly created variable. A pop-up will appear indicating that we are assigning a NULL value to our variable. That just means we have left the variable unassigned – which is what we want, so press Yes to dismiss this dialogue.
  9. We need to repeat those steps again to create the rest of our variables. Follow the steps we just took, create the following variables:

    Variable Name Select Field Initial Value
    vInvoiceAmount Value (blank)
    vRowCount Value (blank)
    vTableRow Value (blank)

    Note: We didn’t talk about RowCount or TableRow yet, but we’ll use those as we move on to our looping.

  10. With the all the required variables created, we can get to our first step in the bot building process – launching our browser and navigating to the page we’ll be using for our automation. From the commands tab on the left side of the screen, click and drag the Open Program/File command over on to the Actions List. As soon as you drag this Open Program/File command over, notice that it pops-up with a context menu asking for a couple parameters.
    1. The Step 1 field is the Program/File Path. Press the browse button next to this field to open a windows browser window. Here, you’ll give the specific instruction to open a specific application. In the case of this tutorial, we want to select the Google Chrome executable file. For me, that’s located in C:\Program Files (x86)\Google\Chrome\Application. Your path is likely very similar if not the same. In that folder, select the chrome.exe executable and press the Open button to close the dialog.
    2. The Step 3 field is the other field we’re concerned with in this command. In step 3 we give a parameter to be used with the application selected in Step 1. For us, that parameter will be the URL of our tutorial page: https://www.automationanywhere.com/automationanywherelabs/currency.html
    3. Press the Save button to close the Open Program File Command.
  11. You should now see your first command showing up in the Actions list in the middle of the screen.
  12. Press the Save button with the disk icon at the top of the screen to save this new bot.
  13. When prompted, give the name CurrencyConversionExercise.atmx and press the Save button to close to Save Task dialogue.
  14. Once the bot has been saved, press the Play button to launch the bot.
    1. In the bottom right corner of your screen, you should see a dialog window appear which shows the progress of your bot’s execution. In our case, out bot only has 1 line, so that window will pop up quickly and close as the bot has finished its execution.
    2. As the bot runs, you should see that Google Chrome opens and automatically navigates to the page we provided in the Open Program/File command.
  15. Leave this window open as we’ll use it for the next commands which we’ll be adding.
  16. Looking at the exercise page itself, we see there is an HTML table. The table has a header and 5 numbered rows. Each row contains a separate invoice, and each column has some different invoice details. We mentioned in the requirements that we want to grab the Amount Due and the Date column for each of the invoices. One way we could do this is by adding an Object Cloning Command to grab the date from row 1, an Object Cloning Command to grab the amount from row 1, an Object Cloning Command to grab the date from row 2, an Object Cloning Command to grab the amount from row 2, etc. That would work…but what happens when the page has 6 invoices instead of 5? Our code would only grab the top 5, then stop. We’d have to constantly update the bot every time the count of invoices changed. That brings us to our next tenant of problem solving – Repetition. Repetition allows for us to repeat a sequence of commands a certain number of times, or until a certain condition is met. In our case, we know that there is a table on the form, and we know the table is a header + some number of rows (in our specific case – 5) so we would want the bot to do certain things for every row of that table. In that way – it doesn’t matter if there are 15 rows, or 2 rows…the bot will always be able to recognize the row count and repeat the commands we outline a set number of times. In programming, repetition is referred to as looping or a loop which is how we will refer to it shortly in this tutorial.
  17. Let’s have the bot figure out how many rows are on the page. Click and drag the Object Cloning command into the Action List.
    1. The Object Cloning window will appear. From Select Window dropdown, select the window titled Automation Anywhere Labs – CurrencyConversion – Google Chrome
    2. If you don’t see this window title, make sure that the Google Chrome window which launched as a result of us running our bot for the first time is still open. If it’s open, but opened as a tab behind another browser, click and drag the tab off the browser so that our target browser session is open in its own chrome window.
    3. Click and hold the Capture button. Automation Anywhere will automatically switch to the application indicated in the Select Window dropdown – in this case our Google Chrome CurrencyConversion exercise page. With the left-click on your mouse still held down, highlight over the table on the page until there is a red box flashing around the outside of the button. Once the red box has highlighted the target element, you can release the left-click.
    4. The Automation Anywhere Workbench should set the focus of your screen back to the Object Cloning properties window.
    5. We’ll need to set up which action we need to take on this object. In the Select Action to Perform dropdown, notice there are several options we haven’t seen yet. This is because we’ve selected a table now instead of individual fields. Select Get Total Rows as the Action to Perform.
    6. In the Assign to Variable drop down, select vRowCount.
    7. Press the Save button to close the Object Cloning window.
  18. With the vRowCount value already set, lets set up a loop. From the Commands pane, click the + sign next to the Loop command to see all possible loops. Since the Object Cloning command should be setting the vRowCount variable with the count of rows in the table, we should know how many times we want the loop to run. Click and drag the Times loop command to the Actions List under our existing Object Cloning command.
    1. In the Loop command properties window, there are several options in the Loop For section which allow for controlling how often a loop should occur. With the Times radio button selected, click into the Times input field and press F2 to bring up the Insert Variable window.
    2. Select the vRowCount variable in the Insert Variable window and press Insert.
    3. Back on the Loop command properties window, press the Save button to finish creating the loop.
  19. The loop that gets created has 3 total lines.
    1. The first line of the loop starts the loop and indicates how many times the loop will run – in our case vRowCount times
    2. The second line of the loop is in green, and as we saw with the if statements we used in the last lab, that means that it’s a comment line. It’s a good practice to fill in comments that get auto added as well as any additional comments that you think may be helpful as you review your code in the future.
    3. The last line Ends the loop.
    4. Important Note: Everything inside the loop will execute however many times the loop runs. This becomes VERY important as there are some things you need to do over and over, and some things you only want to execute once.
  20. To make sure our loop is working, click and drag a Message Box command inside your loop.
    1. Once added, the Message Box command properties window will appear. In the Please enter message to show the user text field, type the text leaving a space after the word:
      Row
    2. Press F2 to insert a variable with our static text.
    3. We’ve used our own custom variables several times already. We’re now going to use a System Variable that is specifically for us with loops called Counter. You’ll need to scroll down inside of the $SystemVariables$ section to find it.
    4. Once selected, press the Insert button to close the Insert Variable dialogue.
    5. Back in the Message Box window, check the box next to Close message box after 5 seconds and press the Save button.
  21. Press the Save button to save your bot, then press the Run button with the green arrow at the top of the Workbench window to run the bot.
  22. How many times did the iteration message box window come up? It should have come up a total of 6 times…one time more than we expected!! What happened!?!?
    1. Looking back at the table on the page, we can see it has 5 rows of data…but it also has a header row, which is how we ended up with 6 iterations of our loop instead of 5. Its not a problem, and it doesn’t mean we did anything wrong – its just something we need to be aware of as we set the bot up to take specific action on the non-header rows of our table.
    2. Disable the Message Box command in your bot by right clicking the command in your Actions List and selecting Disable.
  23. Now that we know how our loop will work, lets figure out how to extract some data. Click and drag an Object Cloning command inside the loop.
    1. The Object Cloning window will appear. From Select Window dropdown, select the window titled Automation Anywhere Labs – CurrencyConversion – Google Chrome
    2. Click and hold the Capture button. Automation Anywhere will automatically switch to the application indicated in the Select Window dropdown – in this case our Google Chrome CurrencyConversion exercise page. With the left-click on your mouse still held down, highlight over the table on the page until there is a red box flashing around the outside of the button. Once the red box has highlighted the target element, you can release the left-click.
    3. Once the Object Cloning window appears again, take a look at the Select Action To Perform dropdown. Select the option that says Get Cell Text By Index. For the Row field, press F2, and select the Counter value from the Insert Variables dialogue.
      1. Using Counter here allows our bot to be dynamic – in that if there are 20 rows, or 2, it will be able to grab the data from whatever row its currently working on.
    4. In the Column field, we don’t have to be as dynamic, as the column that stores the Date and the column that store the amount due should always be the same. Looking at the table on the exercise page, the date value is in the 5th column, so enter 5 in the Column field.
    5. Finally, we have the Assign to Variable dropdown. Select the value where we want to store the date for each row: vInvoiceDate.
    6. Press the Save button to close the Object Cloning window.
  24. Repeat the previous steps to complete the Object Cloning step to extract the Invoice Amount. For reference, your Object Cloning window should look like this when you’re done:
  25. At this point there are a total of 4 lines inside of our loop.
    1. The comment line that says to enter your commands to loop
    2. A commented outline for our old message box
    3. 2 lines for object cloning
  26. If your lines are in a slightly different order, that’s fine…but we’re going to move some things around a bit, so as long as you get the same result, you’ll be ok. Click and drag the comment line on onto the second of the Object Cloning lines so that the comment line becomes the last line within our loop. We want to update the Message Box line so that we can update the text that it displays the text that we have extracted out of each row. After moving things around, your bot should look like the image below.
  27. Double click the Message Box command so we can edit it again. At the end of the Row $Counter$ line, press the Enter button on the keyboard to go on to the next line.
    1. In the next line of the Message Box text field, type the text Invoice Date followed by a space.
    2. Press F2 to bring up the Insert Variable window and insert the vInvoiceDate variable.
    3. Repeat those steps to also add the Invoice Amount and vInvoiceAmount variable to the message box text.
    4. Press Save to close the Message Box configuration window.
    5. Finally, right click the currently-green message box command in the Actions List and select Enable from the right-click context menu.
  28. Press the Save button to save your bot, then press the Run button with the green arrow at the top of the Workbench window to run the bot.
  29. When the bot runs, you should get all the detail from the text from the 5th and 6th column of the HTML table for each row. Unfortunately, that still includes the text Date and Amount Due £ from the header row. To fix that, we’ll need to use one of the conditional statements that we learned about in exercise 3.
    1. In the Commands pane, click the ‘+’ next to the If/Else command.
    2. When the If/Else command expands, click and drag the Variable if command right above the first Object Cloning command in your loop…so that the if statement will occur before the Object Cloning command executes – which means you will drag it on to the green comment line, and release once that comment line is blue.
    3. In the If configuration window that appears, make sure that the Variable radio button is selected, and press the Edit button near the IF Condition at the bottom of the window.
    4. We want to do the Object Cloning commands ONLY if we are past the first iteration of our loop (the header row). In the If Variable window that appears, click into the Variable field and press F2.
    5. From the Insert Variable window that appears, select the Counter value from the System Variables section (the same value we used for our Object Cloning commands)
    6. For the Operator drop down, select Greater Than(>)
    7. For the Value section, make sure that the Fix radio button is selected, and enter the number 1 into the field.
    8. What we’re setting up here is a conditional statement that will allow for us to run commands ONLY if the Counter value is greater than 1. Since we know that when Counter = 1, that’s our header row…so we really don’t want to do any Object Cloning extraction there or try to take any action with the data in that row.
    9. Press the Save button to close the If Variable window and save again if the If statement window is still showing.
  30. With the If statement in place, we’ll need to re-arrange our code some if we want our Object Cloning commands to only execute on the non-header rows. Click the first of the Object Cloning commands inside of the Loop. Press and hold shift, to click on the Message box command inside the loop. This should highlight all 3 lines (The 2 Object Cloning lines and the Message Box line).
    1. Click and drag all 3 lines on top of the comment line inside of the If statement block.
    2. Your code should look like this after the move:
  31. Since we’ve been in the (good) habit of incrementally testing our code for this lab, press the Save button to save your bot, then press the Run button with the green arrow at the top of the Workbench window to run the bot.
  32. You should see an outcome very similar to our last test, however we shouldn’t see the Message Box window with the header info, only Message Box windows for the 5 data rows.
  33. We’re now at the point where we need to do the currency conversion. There are several currency conversion bots on Bot Store. We’re going to use one specifically that allows for historical currency conversions called the Look Back Currency Conversion bot.
    1. Check out the video on Look Back Currency Conversion bot download page to get a brief idea of how the bot works and what it does.
    2. Click the Get Bot button on the bot’s webpage to download the bot. The bot will download as an MSI file.
    3. Upon running the MSI file, you will be prompted to provide a license key which you should receive via email after downloading the bot. This key is also available in your Bot Store My Downloads page.
    4. Finish the installation via the MSI to complete the installation of the Look Back Currency Bot.
  34. Let’s take a quick look at what just got installed:
    1. Navigate to the C:\Users\<your user name>\Documents\Automation Anywhere Files\Automation Anywhere\My Tasks\Bot Store\Look Back Currency Conversion-Automation Anywhere directory to find all the files which installed as a part of our bot.
    2. In the root of this folder, you will find a ReadME PDF. The ReadME explains the purpose of the bot, the different currencies that the bot supports, as well as some examples of how the bot works.
      1. In short, the bot is designed to accept an input currency, an output currency, an input amount, and an optional date value. The bot will then execute and return an output amount and a result value to whatever task called it.
      2. The documentation also mentions variables which are required for the bot to run:

        Value Type Description
        vInputCurrency Input 3 Letter Currency Abbreviation
        vOutputCurrency Input 3 Letter Currency Abbreviation
        vInputAmount Input Number value. No commas, spaces, or dollar signs. Decimals are OK.
        vCurrencyDate Input (Optional) “07/13/2018” – date is in quotes to force bot to treat as string
        vOutputAmount Output Input Amount converted to the target currency rounded to the closest .01.
        vResult Output Should be Success if bot executed correctly, otherwise would be set to error message from subtask which could be checked for after calling the subtask.

         

    3. Inside of the My Tasks directory, you’ll find 2 atmx files – a Master.atmx, and a LookBackCurrencyBot_Subtask.atmx.
      1. The Master.atmx in this bot is used only to demonstrate how to interact with the bot’s secondary atmx file. Feel free to open this in your workbench to see how it executes.
  35. Let’s start to integrate this Bot Store bot by creating the variables that it needs to run. We already have a vInvoiceDate and vInvoiceAmount – and even though those variables aren’t named exactly like the subtask has them, we can still map our values to those inputs.
    1. In the Variable Manager on the right side of the screen, add the following variables

      Variable Name Value
      vInputCurrency GBP
      vOutputCurrency USD
      vOutputAmount blank
      vResult blank

       

  36. In the documentation (and the table above) we can see that the date to be passed to the Look Back Currency Conversion bot is supposed to be surrounded by quotes.
    1. Click and drag the Variable Operation command from the Commands pane directly below the Object Cloning command that extracts the Invoice Date.
    2. In the Variable Operation configuration window that appears, choose vInvoiceDate on the Specify Variable drop down.
    3. In the Specify value for $Select variable$ field:
      1. Type in a quote sign
      2. Pres F2 to insert a variable – selecting the vInvoiceDate from the Insert Variable window
      3. Type in another quote sign
    4. Press the Save button to close the Variable Operation Window
  37. In the Translation lab, we used a bot from Bot Store that installed a MetaBot. In this lab, we’re going to use a subtask…in that we’ll be using one of the atmx files from the Look Back Currency Conversion bot that we will call directly from our bot.
    1. Note: There is nothing special about an atmx file that makes it a subtask. Its about the way that the atmx file was created and designed to be used. In this case, the Look Back Currency Conversion bot has an atmx file that was designed to take in values and return values back to a parent task – so we’ll be using that functionality in our lab atmx.
    2. In the Commands pane on the left side of the screen, click the ‘+’ next to the Task command.
    3. Click and drag the Run Task command into the Actions List placing the command right above our Message Box command.
    4. In the Run Task configuration window, press the browse button to navigate to the path where the Look Back Currency Conversion bot was installed and select the file named LookBackCurrencyBot_Subtask.atmx.
    5. The path is likely C:\Users<your user name>\Documents\Automation Anywhere Files\Automation Anywhere\My Tasks\Bot Store\Look Back Currency Conversion-Automation Anywhere\My Tasks\LookBackCurrencyBot_Subtask.atmx
    6. Below the Select Task section of the Run Task configuration window, there are 3 radio buttons – Repeat, Speed, and Variable. Select the Variable radio button.
    7. On this screen, we can map our variables to the variables that the subtask is expecting. Press the Quick Map button. Quick Map will take any variable from the Main Task that matches an already created variable on the Sub Task to create an association. This should map a total of 5 of our variables.
    8. We’ll still need to create a mapping for our Invoice Amount and Invoice Date as our variables didn’t match the Sub Task’s directly. Click the Add button next to Quick Map.
    9. Scroll down to the bottom of the mapped variables window to see that a new line was added where currently Select Value is set on both the Main Task variable and the Run Task Variable.
    10. Select vInvoiceDate from the Main Task variable dropdown, and vCurrencyDate in the Run Task variable drop down.
    11. Add one more mapping by clicking the Add button again and create an association with vInvoiceAmount and vInputAmount.
    12. Press Save to close the Run Task dialogue.
  38. Update the Message Box command to now include the vOutputAmount and vResult in the message it displays for each row. This will let us know if our bot is working correctly with the subtask before we start building out any more logic.
  39. Press the Save button to save your bot, then press the Run button with the green arrow at the top of the Workbench window to run the bot.
  40. When the bot runs, it should extract the values (like it did before) and use the Look Back Currency Conversion subtask to convert the Invoice Amounts from GBP to USD for the date specified. If your code worked – awesome! If not – no problem, take a look at the code snippet below and see where yours might be off. If you’re still having trouble, pay close attention to what the Result value is in your Message Box to see if that can clue you in on what might be missing.
  41. One thing to note here, if you paid close attention to the pop-up that appeared, the date that showed up in the Message Box was NOT formatted the same way that we extracted it from the HTML table.
    1. When mapping values to a subtask like we did, those values go bi-directionally – meaning that if a value is updated by the subtask, it will be reflected in the main task. In this case, the Look Back Currency Conversion bot formatted the Invoice Date value that we had mapped to the date format that is required for the API that its calling. That value was also updated in our main task – which is why the date shows as YYYY-MM-DD instead of MM/DD/YYYY as the HTML table has it.
  42. Assuming all your data was correct, we’re done with our Message Box, so please disable that line again by right clicking and selecting Disable.
  43. We’re on the home stretch. We still need the bot to do 2 more things: Enter the OutputAmount value into the field for each row of the table, and finally press the submit button. We’ve already done basic Object Cloning with input fields, but now our input field is inside of a loop…which makes filling these input fields a bit more challenging.
    1. Click and drag an Object Cloning command from the Commands tab right below our now disabled Message Box command (but still before our End If statement)
    2. Select Automation Anywhere Labs – CurrencyConversion – Google Chrome in tine Select Window drop down.
    3. Click and hold the Capture button to capture the first input field for the first data row on the HTML table.
    4. Double-click inside the DOMXPath field of the Select Search Criteria table to copy the value of the DOMXPath.
    5. Open a blank Notepad document and past in the DOMXPath.
    6. Without clicking Save, re-do the Object Clone by clicking and holding capture to repeat the steps above – copying out the DOMXPath for the 2nd and 3rd Input Fields on the table.
    7. A DOMXPath is a syntax for expressing the navigation through a Document Object Model. Think it like an address to our specific input fields. The reason we’re extracting 3 of them is because we want to see if there is a pattern to the addressing of the fields so that we can identify how to dynamically interact with the inputs.
    8. With the DOMXPath for the first 3 fields in the notepad document, we can see that there seems to be a recurring pattern in the way that each field is uniquely addressed.
    9. The tr tag (which in HTML is used for Table Row) increments for each of the input fields. We’re going to need to use a variable inside of the DOMXPath so that we can dynamically interact with each input field.
    10. In the first line of our Notepad doc, replace the 1 inside of the tr brackets with an x. We’re doing this so that when we use the insert variable command, its easier for us to make sure we’re replacing the right thing.
    11. Copy this entire first line (the one with the x) to your clipboard.
    12. Back in the Object Cloning configuration window, double click the DOMXPath value field to highlight the text and delete it.
    13. Paste in DOMXPath line from your clipboard.
    14. Using your arrow keys, move the cursor in the DOMXPath value field over to where our x was and delete it, leaving the cursor inside of the tr brackets
    15. Press the F2 button to bring up the Insert Variables window and select to insert the variable vTableRow which we created at the beginning of this lab. (we didn’t give this variable a value yet, we’ll take care of that after setting up this Object Clone)
    16. Because we’re going to be using a custom DOMXPath for finding our input field, we’ll need to make sure that the bot is looking at that path only for finding the correct input. In the Select Search Criteria table, press the binoculars button next to the Path and HTML ID fields to exclude them from consideration during the bot’s execution as they reference a particular input, not a dynamic location like our DOMXPath.
    17. In the Select Action to Perform dropdown, select Set Text.
    18. In the Text to Set field, press F2 and insert the variable for our converted currency – vOutputAmount
    19. Press Save to close the Object Cloning window. For reference, the configuration should look like this:
  44. We need to set up that vTableRow value so that filling those input fields dynamically will actually work. A logical first thought would be “Why don’t we just map it to the Counter value?” – which is a good idea but wouldn’t work correctly in this scenario. Let’s understand how to set up vTableRow.
    1. We know that our vCounter value keeps track of which iteration of the loop we’re on.
    2. When we’re in the first data row of our HTML table vCounter is 2 (because vCounter=1 on the header row).
    3. Looking at our Notepad document again, we need to make sure we get a 1 for that first data row to fill in to our vTableRow variable. To make sure that the value we need for tr is always in sync with our vCounter, we’ll said vTableRow to vCounter -1.
    4. From the Commands pane on the left, drag a Variable Operation command right below the Run Task command that executes the Look Back Currency Bot.
    5. In the Variable Operation configuration window, select vTableRow in the Specify Variable drop down.
    6. In the Specify value for $Select variable$ field, press F2 and select to insert the Counter variable from the System Variables section.
    7. Once counter has been added, type in -1
    8. Press Save to close the Variable Operation window
  45. The FINAL command we need to add is to click the Submit Button. Where do we put it though? Everything we’ve been adding so far has been inside of a conditional statement inside of a loop. If we added the button click there, the Submit button would be clicked EVERY TIME the loop runs. In our case, we only want the Submit button to be clicked once all the fields have had their data entered.
    1. Click and drag an Object Cloning command from the Commands tab to the end of the Actions List. This command should go below the End Loop and become the new last line of the entire automation.
    2. By this point you’re probably quite familiar with setting up an Object Clone, so try to do it on your own. A screenshot of the correct configuration is below in case you get stuck.
  46. Press the Save button to save your bot, then press the Run button with the green arrow at the top of the Workbench window to run the bot.
  47. The bot should launch Google Chrome automatically extract the Invoice Amount and Invoice Date for each row, perform a lookback currency conversion, fill in the converted amount into each row’s input field, and press the Submit button at the end.

Recap

WAY TO GO!!! You just created a dynamic (and frankly pretty complex) bot! There were a lot of new concepts that we introduced with this lab – so be proud of your bot and go show it off. We used some new commands we hadn’t used before and learned to integrate a subtask into our automation. Creating and using subtasks is a great way to design your bots with reusability in mind. If there are things you need to do over and over that don’t have a ton of variation in them, they may be a good fit for a re-usable subtask. Additionally, using bots from Bot Store is a natural step to accelerated bot building. Make it a habit to check in Bot Store as you start a new project to see if there are bots that can help with building your bot more quickly. Lets recap cover a couple core concepts that we learned

Problem Solving Concept – Repetition
Repetition in problem solving allows us to repeat a series of commands until a certain condition is met. In our case, it was to repeat the commands 1 time per row in the HTML table. Using our Message Box commands, we also saw how important it can be to make sure that we know exactly what is happening in each iteration of the loop – and that we can use selection statements to run (or not run) certain commands each time the loop iterates.

Bot Building Technique – Dynamic Commands
In our other labs, all our commands were pretty static…in that if the number of fields changed, or we had to interact with a new field, we would have to make changes to our bot. In this lab, the bot was created somewhat dynamically – in that if the invoice table had 10 rows or 5 rows, the logic would still work, and we wouldn’t need to update our bot at all! Its not something that can be easily done (or done at all) in all situations – but as a bot builder, you should always be looking to get things done as dynamically as possibly keeping in mind possible changes that the application/web page may see.

Bot Building Technique – SubTasks
Subtasks allow for developers to create compartmentalized logic that can be re-used in multiple bots to help speed up the bot building process. In this exercise, our subtask came from Bot Store. In your own RPA initiatives, you may use a mix of Bot Store bots as well as sub tasks that have been created to accomplish objectives specific to your internal applications. Keep the concept of subtasks in mind as you start to build bots and see where particular tasks are the same and happening over and over. A page login, doing a lookup on data, data conversion…all of these could be examples of where a subtask could be created to help speed up your bot building process.

Next Steps

Excellent work on this lab. If you haven’t done so, I’d encourage you to go and look at the “Want some more practice” sections on this, and the other tutorial pages to further solidify your understanding on some of the topics covered. Go build on the things you’ve learned here to create awesome bots and Go Be Great!
Want some more practice on this page?

  • Our DOMXPath approach is pretty dynamic – in that it would work even if there were more rows added – however looking at the properties of the Object Clones we did for the Input fields – what other value could you use to dynamically use to fill each input that would be even MORE resilient to page changes?
    • Hint: take a look at the ObjectID for each input.
  • We didn’t HAVE to do the custom DOMXPaths to complete this lab – instead of using the custom DOMXPath in the Object Cloning command, try doing an Object Clone into the first field only, then using keystroke entry commands to complete the remainder of the page.
  • There are several currency conversion bots on Bot Store. Test out integrating one of the other currency conversion bots into your process.
    • Note: Don’t stress out about making sure that the currency conversion is a historical one when using other Bot Store bots. The validation on the exercise page will probably tell you everything is wrong – that’s simply because it’s going off the expected numbers from the Look Back Currency Converter bot. It will still be good practice to integrate a Bot Store bot which may be a MetaBot or a different subtask.