Best practice when using "For Each" when data scraping in Citrix-based system

I’ve got a list of ID numbers that I need to enter in a Citrix-based system and scrape the data that is returned.

I use the “read csv” activity that contains the ID numbers to load them into a DataTable.

I then use “for each row” to type the ID number into the Citrix system, choose the file to open, open the file and scrape the data I need.

My issue is that some of the ID numbers do not return any documents, and instead return a message “Document not found”. My goal is to recognize when this occurs and just move onto the next row/ID number with out trying to scrape anything.

I’m trying to do this using the “Image exists” activity followed by an “If” activity. The “if” activity enables me to define two activities, one “Then” if the “document not found” image exists and “Else” if it does not.

I cannot figure out what to put in these activity boxes to make my flow work correctly.

Can anyone give some advice on if this is possible or if I need to use some other activity to achieve this?


You’re on the right track.

In the Then branch (when the “Document not found” image is found) put your clean up code - whatever actions are needed to get back to being able to put the next ID.
In the Else branch, put your scraping activities.

Do note that although both Then and Else branches hint to “Drop activity here” that activity might as well be a Sequence (or similar) containing additional activities.


1 Like


Thanks for your response. Good to hear I’m on the right track.

Could you be more specific about the “clean up code” you refer to. Are there specific activities that will redirect back up to the “for each” process? Like a “go to” or something similar?


Dan W.

There’s no need for a GoTo - when the branch ends (no more activities) execution will go up in scope back to the for each.

If you’re not sure how it works, I’d suggest running your workflow step-by-step - run the workflow from the Execute->StepInto (each press will move it forward one step) and just watch how the executio goes, it should show more than I can explain in words :slight_smile:

By “clean up code” I meant whatever is needed so that you’re able to enter next ID in the application - closing a popup, emptying a text box, pressing a back button etc. No particular activity.