Is it possible to run a foreach by only using the BPM Workflow elements?

, ,

I’m using some BPM elements to Approve/Unapproved some PO’s and change a comment text at the Lines level in an updatable BAQ (a single row can be changed or several ones), right now I have a custom code where I do a foreach for the ttResults table then run the GetByID for each PO, change some of the values and finally run the update method. After the Update method I link it to the foreach custom code again but when doing this I’m getting a NullReferenceException (both values are updated not matter the exception message). Do you know if there is a way to do a foreach avoiding this error message?

I have wondered about this before as well, and to the best of my knowledge, you can’t perform any type of looping with workflow designer. Maybe someone else can verify.

1 Like

How would you get out of the loop that you have shown there? I don’t see a condition that would kick you out, it would just try to keep going forever. Did you just run out of rows so you got the null reference exception? Can you put some message boxes in your loop and see if it is in fact looping?

You can do looping in the designer, you need to get creative but it is doable.
Declare a variable (counter)
1 Initialize it to 0
2 use it to address the “right” index of your dataset/table
3increment counter
4 check if counter <= datatable.records loop back to 2 else
5 break
But it is painful

3 Likes