Multiline record into queue. I have invoice data in the excel. single invoice data is in multiple lines. Header row has details about customer, multiple lines items for service and parts. I want to put all these rows for single invoice in Queue item for multi bot execution. Screen of the data is attached and color coded to show the same record.
You cannot add complex types like datatable directly…for that we serialize them as json array and can add the data to wueue as a string and then deserialize again to datatable in performer
Queue stores the data in the database in the background. So, it is best to structure your data as a JSON object and then convert it to a string and store it in the queue (specific data).
While in the performer, de-serialize the string to a JSON object and use it in your performer wherever data is required.
Here is how to read an Excel file and group rows together into one queue item:
Use your typical methods to read the Excel file into a datatable.
In my example I have an Excel file that contains CSV definitions with one row per CSV column, so I need to group them so I have one row for the definition and a column that contains JSON for all the other rows for the same definition.
Add a column to store the JSON:
Then loop through the datatable:
Now we are in the loop and for the CurrentRow of data will filter into a new datatable to get all matching rows for CurrentRow(“MAPPING_NAME”) which I think in your case would be Customer Number. I actually need to group them by MAPPING_NAME and BUSINESS_ID so you’ll see that in my filter:
Now every row in the datatable has a column (in my example, FIELDS) that has the JSON for the grouped data, and we don’t need those columns we grouped, so remove them with Filter Data Table:
Then remove duplicates from the datatable so we have only one row for each MAPPING_NAME/BUSINESS_ID which in your case is Customer ID.
(From row In DT_Main
Group row By
k1 = row("BUSINESS_NAME").ToString,
k2 = row("MAPPING_NAME").ToString
Into grp = Group
Select grp(0)).CopyToDataTable
Now that the data is properly grouped in the datatable, use Bulk Add Queue Items to add them to the queue: