Using For Each loop to start multiple new processes with workflows

  • 20 December 2016
  • 3 replies
  • 2 views

Badge +8

 The scenerio:

 

Each quarter a campaign will start that where each of our location managers have to complete a survey. There could be 150 locations or more. The idea is to build a list or facility directory. Each location will have a status of active or inactive. What I would like to do is use this directory to kick off a new process for each active location. Ideally the administrator of the form would open a form designed to "Kick off the campaign" by clicking a button. Once the button was clicked a process would be opened for each facility required to complete the survey. For each process a workflow would send each location manager an email requiring them to action the survey. An escalation would be put on the user task to remind them daily to complete the survey. 

 

So I built a facility directory with a status of "active" or "inactive". I then built a generic form and a workflow with a single user task. I built a third form with a button to trigger the campaign. I added the facility directory to the campaign form so that I could do a read method and filter for only the active items. I was hoping that on the click of a button some sort of "for each" rule would loop through the list and open a process for the active facilities. So far I have had no luck in accomplishing this task. 

 

Am I going about this the wrong way? Is there another way I should be looking at this? Am I on the right track? Does anyone have a suggestion on how I might directly approach this requirement to make it work. Any ideas are welcome and appreciated.

 

Thanks,

Bryan Peters


3 replies

Badge +3

Hi Bryan,

 

I currently use the for each loop to fire off workflows.  You can either do that in form, or trigger a workflow which does the looping in the background.  If you do it in workflow, you will need to use the Create Reference activity firs hen the For Each to do what you need it to do.

 

Regards,

 

Nathan

Badge +8

Thanks Nathan. I guess I am unsure how to use the For Each loop in the workflow. I Created a reference but I had no idea what I was doing. I am assuming the reference will be for it to read the Facility Directory where it will be doing a for each loop right? I did not fin an option to tell it which control to use to send the workflows.

 

Thanks,

Bryan Peters 


15400i1D87C22C0FD80D86.png
Badge +3

Hi Bryan,

 

The create reference in essence gets a list of items to loop through and also creates a data structure so you have access to the data for each item.  The reference is then used in the loop activity to loop through each item.  What you seem to be missing from your example is a line back into the for each loop so it increments to the next item like in the example i have attached.

 

Regards,

 

Nathan


14444iF6731A766100B1B0.png

Reply