LibraryEASYProcess Reference ManualProcessesServicesProcessFlowWorkshopExitForEach

ExitForEach Overview

If you wish to exit a ForEach loop, but do not want EASYProcess to keep track of the loop index, ExitForEach can be used to stop the looping. This forgets the indexing so that if you would like to reference the SelectorValue again, you can do so without EASYProcess adding the automatic indexing.

For example, if the selector node is WorkData/Inquire, and you wish to exit the loop after two iterations out of the total five, any time you reference the node again, EASYProcess will turn it into WorkData/Inquire[1]. ExitForEach returns the reference back to WorkData/Inquire.

ExitForEach Use Examples

ExitForEach Use Examples

Basic Use Example

In this example, we query to find all the items in the cart. We then ForEach on the results. Each iteration checks how many items are in the cart so far. If at any point we reach the limit of items per cart, we exit the ForEach and return a message to the user that the items cannot be added to the cart.

When the ExitForEach runs, the service output returns a True/False flag indicating the exit as successful or failed as well as the index that it was on when the exit occurred.

Not Exiting the ForEach Loop

Exiting the for each loop if you do not wish to continue it, is good practice, but not always necessary. The example below iterates through all the results of GetUserId, but when it finds the correct one, it shows a message to the user with SetWindowsAttributes. Since the process is ending once it finds the match, there will never be an issue where WorkData/GetUserId is referenced again, but EASYProcess is referencing that node with an index: WorkData/GetUserId[2].

The ExitForEach could still be used here to uphold good development practices. That way, when future developers make changes to the process, it is possible that they could try to reference WorkData/GetUserId and have undesired results when indexing is still occurring.

Powered by EASYProcess (© 2019 K-Rise Systems, Inc).