Problem with For Each

Hi, I have a for each activity in my workflow. There are 2 records in the datatable. Inside the for each there are activities which do the following

  1. Find some data
  2. Save the data to a variable (there are 3 pieces of data and 3 variables)
  3. Write the data into a web form (3 fields)
  4. Click a button

No I was under the impression that once these activities ended the flow would loop back and run again for the second record. This doesn’t seem to happen so am I using the correct method to loop through the data in the datatable?

Pleas can you advise?

Hi,

Can you share your workflow as screenshot or file, if possible?

Regards,

Hi Yochi, apologies its on a remote machine, I wont get access until tomorrow

But the for each is like this

the datatable contains 2 rows from a read of an excel file

This process works for one line but does not repeat fo the second

Before the for each row Loop, check that how jab rows are there in datatable to be looped
Check this in debug mode

Make sure the file is read correctly, check for the Range mentioned in the Read Range activity

Check if you have added a break activity inside a Loop, that takes the flow directly out of a loop

Hi Rahul, Thanks for the reply

to answer your points

  1. There are 2 rows in the datatable - I have written these to excel as a check
  2. The range is correct as again I have written the datatable to excel
  3. There is no break activity - to be honest that would be obvious

So I am still unsure why this would not loop.

@ieptus

To confirm that you have the 2 rows, put a breakpoint after the Read Range activity and debug it

See in locals pane and check the value of dtimports datatable, that where you can get to know whether it is taking the 2 rows or only one row

Hope this may help you

Thanks

If you are as allergic as I am to reading datatables during debug breakpoints (it’s a love-hate relationship between me and the UI) you can also just use a few extra write line commands as debug:

Writeline YourDatatable.rows.count.toString for the actual number of rows in your DT at that point.
To see the data, use Output Data Table to string and again a writeline to see the raw data.

Place both of them just before your for each row loop as evidence that the DT actually consists the data at the right time in your workflow.

A for each row in data table loop should then simply work, and display your row data with writeline row(n).toString with n being the column number.

strange, you can send the workflow if possible?

create the flow in a new file and see if that shows the same flow to check if something is missing in current flow…

Hi Rahul

Thanks for the reply, will give that a shot, does seem odd

Dave

Hi Jeroen

Did you miss my line about exporting the datatable to excel to see what was captured?

Regards

Dave

Hi Srini

Did you miss my line about exporting the datatable to excel to see what it had captured? Hence 2 rows?

Regards

Dave

Hey David,

No I didn’t. Just offering alternative approaches to help figure out the problem.
In my experience it helps to debug as close to the activity that displays the problem, that’s all.

I couldn’t tell at which point you performed your export to excel, and without knowing your exact workflow I couldn’t conclude if the data was manipulated unwillingly in between the steps, and didnt want to rely on assumptions.

Other than seeing your actual code (are you allowed to share your actual workflow with us?) I can’t think of a reason why a for each row workflow wouldn’t repeat itself if 2 rows exist in the DT. You screenshot example seems valid, other than the unfinished activities in it (which are obvious just there for example, I know)

Help us help you :slight_smile:

I appreciate you looking, I still cant seem to put my finger on it but have different issue with a grid that is driving me nuts before I can test the whole For each.

I would share the workflow as its easier for everyone but i’m working on a remote machine with limited access

Still not sure why this didnt work, I deleted the fore each and then re-added and seemed to work fine from that point???

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