How can i get data from datatable from where last time flow stops?

I have created one workflow in that workflow I am using datatable to store some details .but if its fails at some point at that point details are store in Data table When i am running the script again then script start running from that point and stores data onwards from last times where flow interrupt .how can i merge previous data and continue from new one?

You should be doing proper error management ie Try/Catch. In the case of an exception you would have to write the data in the datatable to an Excel or CSV file so you can read it later.

But suppose if the flow stops and 5 rows are store in data table .then from next time the value is about to store from 4 row in data table then how it is possible because till 5th its already store

You have to deal with that in your process logic. This is why a looping process like this isn’t ideal, if you can avoid it. It’s better to work from a queue so it’s just “get an item, process it, get the next item”

@Aksh_7

Use a log message
And pass the value as

dt.rows.indexof(Yourdatarow)

So that you will get index of the eachrow until the bot stops

A Log Message won’t make it so the automation can pick up where it left off when they run it again.

@Aksh_7

while running the bot again

with the help of log message you will get the index of the row and use this before the process

datatablevariable=dt.AsEnumerable.Skip(index).CopyToDataTable

pass the last index which you get after the flow stops and your
the flow get starts with the next rows while you run next time

cheers

Hi @Aksh_7

To merge the previous data stored in a DataTable and continue adding new data in subsequent runs of your script, you can follow these steps:

  1. Initialize the DataTable: Make sure you initialize the DataTable at the beginning of your workflow. This should be done only once, not inside a loop or conditional block, to avoid overwriting existing data.

  2. Load Previous Data: Before adding new data to the DataTable, check if there’s any existing data from previous runs. You can do this by reading the DataTable from a file (e.g., CSV) where you previously saved it.

  3. Append New Data: After loading the existing data, you can append new data to the DataTable as needed during the current run of your script.

  4. Save the Updated DataTable: After processing and adding new data, save the DataTable back to the file (e.g., CSV) to preserve the merged data for future runs.

Thanks!!

How would the next run of the job get information from a Log Message of the previous job?

You can add one more column to the end of your table called Status. After each row getting processed update the value of Status row as Completed. Also first check the value for Status row while processing, if it is completed simply skip the row. This way, if first day you have completed/processed first 5 rows, their status column value will be completed, so next day when bot runs again, it will skip these rows and start from 6th row and whenever completes, will mark that row as completed.

1 Like