The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Workflow Duplicate Activities

Beth11
Giga Guru

Not the best title, but hopefully my description will clarify.

I have a workflow with multiple loopbacks in it. It's working (almost) entirely as desired: approvals and tasks are only reset back to 'requested' or 'open' if the workflow calls for it. Work can progress normally on each workflow. The problem is this: I've noticed that when it loops back from certain points, I start to see duplicate activities. If a 'change value' block would have run once, it runs an additional time for each time the workflow has been back over that spot: might be once if it's never looped back from that position, it might run multiple times, depending on how many times the workflow has looped back. This doesn't seem to cause problems with tasks or approvals, but with notifications it means that users are getting hit with duplicate emails.

The loop looks something like this (this is simplified, but the active players are all here):

sample_workflow.gif

In this example, the notification block might fire multiple times on approval, depending on whether or not the approver rejected in the past. If it helps, the workflow is running on a custom table. I'm a bit stuck; I've tried google and the community search, and I don't seem to know how to frame the question. I don't think I want to start including rollback activities; there are places where I don't want to invalidate past approvals (that's actually the point of the switch statement in the full workflow.) If I understand what the wiki is saying about 'rollback to' then I'd rather avoid it.

Here's an example of a workflow context activity history on a context that's looped back several times:

sample_log.gif

As you can see, it's almost like it splits into several workflows executing all at once. This is incomplete, but it gives you an idea.

So my question is twofold:

  1. What is causing these duplicate activities in my workflow log? Is it normal? If not, how do I stop it?
  2. If this behavior is entirely normal for 'looping back,' how should I structure my notifications so they don't fire multiple times? Would creating notifications triggered by an event control for this, or is there more that I need to do?

Thanks in advance for any advice or insight you can offer.


EDIT: Welp, I'm 99.9% sure that I figured it out. Brace yourselves, newbie mistake incoming. Here's a snapshot from my actual workflow, instead of my sanitized example. Check out what happens after "Set State". Yep, that branch is bad news. Rejection Review is getting fired twice, and after that, everything else gets fired twice, too. It spawns an evil twin every time it leaves the "Set State" block.

2015-02-05_16-02-26.gif

Lesson learned. Now to clean up my workflow and pretend this never happened.

Message was edited by: Beth Barnett

4 REPLIES 4

Michael Kaufman
Giga Guru

I prefer to copy the Business Rule, "SNC Approval - Reset conditions" and reuse it for these situations.   Instead of a loopback, restart the workflow.  



I've had trouble with loopback situations like you are showing.   I try to avoid loopbacks if possible.



Mike


I'll look into it. This is a big, complex workflow, so restarting it might not be an option, but we'll see what I can figure out. Thanks for the tip, I didn't think of manipulating the workflow itself. Even if it doesn't eliminate the workflow issues, there are definitely times that people would like to 'start over' with this process, so it will be helpful research regardless.



In the meantime I'm experimenting with the rollback to activity and seeing what I can do with that. I'm also pulling all of my notifications out of the workflow as a palliative, since that's the only place the strange behavior is immediately visible to the customer.



Update: After implementing a rollback activity, it doesn't seem that this behavior has changed at all. Very strange. Also, I don't appear to have the "SNC Approval" workflow on my instance. I suppose I should have specified, but we're on Dublin release. I'll keep poking at the issue. Thanks again.



Update 2: See the question for the very simple answer to my very silly problem.


Hi Beth/Mike,



We also observed this issue on our instance.



We have a complex workflow with 170 workflow activities but in workflow activities history it shows that 302 activities are executed.



Any idea on why this must be happening.


Hi Sachin,



If you read my edit, you'll see that I believe that the problem arose from an unmanaged branch I had in my workflow. If you have any branches like my example does, try putting in branch and join activities and seeing if that decreases the number of extra activities you see executing.



Also keep in mind that you may have loops or other things in your workflow that might lead to a workflow activity executing multiple times.



I would also take a look at the workflow that Mike suggests for some good techniques.