Loops/Iterations in Custom Workflow Activity

Topics: Writing modules
Jul 25, 2014 at 3:22 PM
Hi all. I'm fairly new to Orchard development. I'm trying to create a custom workflow activity that will loop over a collection associated with the main content item that triggers a workflow.
  1. Meeting Time triggers a workflow
  2. Meeting has attendees associated with it and each need to be notified in a separate email.
  3. Custom activity has two outcomes "Loop" and "Finally".
  4. I'm attempting to loop through the list of attendees, set the workflowContext.Tokens once for each iteration.
  5. When the Email activity attached to the Loop outcome gets executed the workflowContext.Tokens are all the same.
How else can I accomplish this? Do I need a separate workflow for each iteration? I'm stuck. Please help.

(Thanks for all the great work that's gone into the platform. It's a very impressive CMS.)
Jul 26, 2014 at 3:39 PM
There is no loop capability released as far as I know but it's possible as demonstrated in this module: https://orchardwatcher.codeplex.com/ Also as far as I understand Piotr has implemented this already in a generic way, I'll ask him to chime in.
Jul 26, 2014 at 3:45 PM
Yes, loops are already there, just not pushed to the main repo yet. I'm working on creating new feature/workflows branch and pushing my code there.
Jul 28, 2014 at 8:30 PM
Piedone: That orchardwatcher module was a big help. The trick was to implement the queue as a serialized list of ids in the activity state and then to point the "Done" outcome of the child branch back to the looping activity. Thanks a bunch.

pszmyd: Can't wait to see the new feature.

Thanks, guys.