Let's open up the Parent bot if you do not have it already open. We will continue from where we left off within the Try block.
We will add a Step action to group together the actions in this section. We have named it Loop, Invoke and add to Excel. You can add a title that makes sense to you. Within this step, let's perform these steps:
- Add a variable to keep a counter as we loop through the data table records. Let's call it currentIteration and choose Number for Type. Check both Use as Input and Use as Output.
- Add another variable to store the output we receive from the Child bot. We will call it dictOutput and choose Dictionary for Type. Check Use as Output.
The dictOutput Dictionary variable stores the key-value pair with all the output variables in the Child bot. In our case, we are using this to retrieve the value of the SO number using the SalesOrder output variable defined in the Child bot.
- Let's add a Number Assign action to initialize the variable currentIteration to 2 as shown in the following screenshot. This is to start reading values from the second row as our data table has headers:
- Let's now loop through the data table. Add a Loop action and choose For Each Row in Table for Iterator, excelTable for Table variable and create a new Record variable called currentrow to assign the current row from the record. When you create the variable, check both Use as Input and Use as Output. Your workflow so far will look like this:
- As the first step of the Loop, let's invoke the Child bot. Add the Task Bot Run action. In the properties, choose the CreateSalesOrder bot. You will see an option called Set RowRecord. If you remember, RowRecord is the variable we added in the CreateSalesOrder bot to pass data. We will set Set RowRecord to the currentrow variable so that we pass the current row to the Child bot as shown in the following screenshot. Also, scroll down the properties and Assign the output to variable dictOutput (not shown):
After invoking the Child bot, the bot returns the SO number. Let's take that and update our Excel sheet.