Waiting for Multiple Jobs to Finish and Saving Arguments

Hello!

I’ve been stuck with finding a solution for my automation using persistent activities and would appreciate any suggestions!

Context:

I have a process in which I have a dynamic number of PDF files. For each file, I want to start a job that runs Document Understanding on the file and returns a DataTable of the results. After all jobs have finished, I want to combine all the returned DataTables into a single DataTable.

The Problem

The part I’m having trouble with is saving the returned DataTables. I’ve tried doing this a few different ways, but haven’t had any luck.

Here’s what I’ve tried:

I used a for each loop over the files in the directory. Within this loop is a Start Job and Get Reference activity from the Persistence UiPath package. This job has two arguments, in_FilePath and out_DataTable. Also within the loop, the JobObject is added to a collection (for all the jobs). After this loop is another for each loop for all the jobs within the JobObject collection. Within this loop is just the Wait for job and resume activity (i.e. waits until the given job is finished, moves to the next that may already be fininshed so it continues moving).


Again, the trouble I’m having is figuring out how to save all the out arguments. I’ve tried creating a variable ListDT = List<DataTable> and a counter variable that is incremented for every iteration. When a job is called, the out_DataTable is set to ListDT(Counter) with the idea that each DataTable is saved in its own index. But ListDT is never populated. I’ve also tried this same method but by initializing the index with a new DataTable first. I thought about using a parallel for each loop instead and having both job starting and waiting activities, but I’m not sure how to save the argument still.


Does anyone have an idea of how I might go about this?

Thanks!

Can you explain more about requirement ?

You meant:

  • Find & process PDF file
  • Add PDF file name into datatable
  • Write result into excel ?

Sure! I can explain it a bit more.

I have a folder with a dynamic number of PDF files and I want to:

  1. Start one job for each PDF (this job extracts values from the PDF, stores it in a DataTable, and returns it through out_DataTable)
  2. Wait for all jobs to finish
  3. Merge the returned DataTables into a single DataTable

I see, Uipath can only process from up to bottom. You don’t need to wait all jobs finished or not.

My solution is:

  • Create a while loops
  • Put activities: Build datatable - dt_Summary, dt_Temp
  • Create a foreach to process PDF.
  • Record information you need into dt_Temp
  • After finish each PDF, you need to merge 2 datatables each other. (dt_Temp → dt_Summary)

Can you clarify what you mean by this?

I don’t want to to process each file synchronously because one file should be able to be processed while another might be waiting for validation. So I’d like to call all jobs at once and then suspend the program until they have all finished.

1 Like

U can try “Parallel” to process flow by async

Thank you for the reply! I finished this automation a long time ago but I did end up using a parallel for each loop.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.