Hi @Michaeljep,
The examples typically include For Each activity to iterate through the list of their records in either a data table or excel or other source, and a populate a list of type List(Of <entityType>)
variable. Once you have the list variable, it can be passed to Batch activities as input.
I am attaching a sample to this answer, here are the steps to use it.
-
Create a new entity called “US States” in your Data Service instance with the following structure -
-
Unzip the attached project, make sure you are connected to your Cloud Account tenant with your Data Service instance and run it.
-
It should create 50 records for the States in your instance and do it via 2 calls.
Batch Create to Data Service.zip (29.2 KB)
Let’s look at what I am doing within the project -
- I read the data from a CSV to a data table ->This can be from Excel or from scrapping as well).
- I set the batch size to 25 records → This is only because I want to update in batches of 25 records. The batch activities support up to 1000 records in a single call. I have used it as a sample to show how to handle scenarios where you may be creating/updating more than 1000 records. You will set the batch size to 1000 in that case.
- I have initialized the list variable to
New List(Of USStates)
to create an empty list.
- I am using a For Each loop to iterate through all records in my data from the CSV.
- For each row from my data table, I initialize a new variable and set the values for the three fields of type USStates.
- I add the new record to our earlier list using
Add To Collection
activity. - Next, I check if the size of the collection has become equal to my batch size.
- If it has, I use the
Create Multiple Entity Records
activity to create all the records using a single call → Due to the If condition in #7, this call will be made only every 25 records in our case. - After creating the records, I clear my collection so the next set of records will be added to it.
- As last step after the For loop, I make sure that there are no remaining records in the collection and make sure to create them before finishing the workflow → This is needed, in case where the count of records doesn’t exactly match our batch size. For ex, if we were creating 80 records, the
If
condition on #7 will have been satisfied on 25th, 50th and 75th record but not again after that. The remaining 5 records will be captured by our last If condition and created after the For loop.