Is it possible to divide "for each" loop code in to small sequence


I have a for each loop which receiving data from excel and this loop have lots of activities lots of if statements that it does not look like a good programing methord.
Is it possiable to still be in the loop but move the activites to other small sequences so that It look good and easy to understand?

its like…

lots of like these… the reason its like that is because I have to run the list of users by doing the same steps again.

Can i devide code or not?

I tried using invoke and arguments but the problem of that is it’s reading the first loop again when im on 2nd invoke or 3rh invoke.

so can someone help?

yes you can do that, but have to make sure you use variables and arguments properly.

1 Like

Yes, you can do it the way you described. Alternatively, you can look into using a Switch activity. A switch is like an if statement, but instead of only having 2 paths to go (Then or Else), you can take a number of possible execution paths based on certain criteria. You can take consolidate all of those different if statements into different cases within the 1 switch activity.

Just note, that each time you loop through the switch activity, it can only go down exactly one of the possibles execution paths.

thanks but im not getting it.
I have attached my code is it possible for any of you to split the code into different sequences?

can someone help me… please
I im trouble my code is very big and i have performance issue…

usually longer implementations flows are divided in smaller parts for several reasons. Calling such a part will be done with invoke workflow:

Passing data/Variable between the calling workflow and the called workflow is organized with arguments:

For slicing a xaml into smaller xamls following technique is provided by studio:

Extract as Workflow

Creates a new workflow containing the targeted activity with the purpose of breaking down a large project into smaller ones. In the place of the extracted activity an Invoke workflow activity is created which enables you to edit and import arguments from the newly created workflow. The arguments are created automatically from the variables used in that activity. The Invoke workflow activity automatically maps the local variables to invoke arguments for the extracted workflow.
taken from:
Studio - The User Interface

I do not want to use invoke as its a for each loop and it will be more then 10 files and arguments is not working… because when i use arguments… it read the whole flow first so the same flow a process in readin 10 time…
which is a bad idea.

we used often invoke workflow also within for each (especially to seperate the main task from the batch processing - reason better quality management, testing purpose…) without any issues and along with arguments in both directions (in, out)

However if you feel that is not fitting to your scenario maybe some other options are to evaluate:

  • potential of doing the same with less activities (combining read row item and text replace in one single assign activity)
  • switching to other flow types e.g workflow chart for another readability experience

Happy automation @Latif