SBX - Search With Button

SBX - Forum Post Title

Workflow fires several times on business process automation

Microsoft Dynamics CRM Forum

Hugo Morillo asked a question on 13 Jun 2018 3:30 PM

Question Status

Suggested Answer

Hello everyone! Hope you're well.

I've created a workflow in a BPF entity, and the trigger is the change of the active stage. Using that, I've created a business process automation, with jumps forward and backward, as long as the stage is on the traversed path. I need to, when a specific stage is the active stage, create a child incident (the BPF is on the incident entity) with diferents parameters.

The workflow has no problems with the jumps, or assign incident to a team, but when a try to create the child incident it fires 3 times (maybe more). So it creates 3 child incidents. I've checked no other workflow or plugin is on the same event. 

CRM Version: Microsoft Dynamics 365 version 1612 (8.2.2.112) On Premise

Thanks in advance!

Reply
Sachith Vidanage responded on 13 Jun 2018 4:56 PM
My Badges
Suggested Answer

I guess your workflow is going through an infinite loop. When the new child incident created the workflow triggers and then again and again. CRM recognizes this and stops the loop; that's why you get only 3 records or a bit more without creating a lot. When a new child incident gets created probably the active stage changes and this causes the infinite loop I believe. Add extra condition (e.g. created on is more than a minute ago or so) before creating a child record which will stop the loop.

Reply
Hugo Morillo responded on 14 Jun 2018 2:18 PM

Can you explain that with a little example?

Thank you.

Reply
Sachith Vidanage responded on 14 Jun 2018 4:59 PM
My Badges
Suggested Answer

Try below for troubleshooting:

Enable auditing for the incident entity. (especially process stage field as this is the field which trigger the workflow)

Uncheck the checkbox which tells the system to delete the successful workflow instances.

Then you perform your activity and check the created incident records' audit log and workflow instances (system jobs). If you see any workflow instances for the child records we can confirm that above is the case.

Reply
Bharat Premji responded on 15 Jun 2018 2:18 AM
My Badges
Suggested Answer

Hi Hugo,

Do you have 3 stages in the BPF?

We have seen this behavior before where if the workflow is set to fire on the entry or exit of a BPF stage it fires the same number of times as there are stages in the BPF.

We got round this by adding a boolean field to the BPF and triggering the workflow from that.

I'm pretty sure this has been fixed in the Online version now

Regards

Bharat

Reply
Hugo Morillo responded on 19 Jun 2018 12:10 AM

Yeah, I think so (it fires same number of times as there are stages in the BPF)

You've created this boolean field and automatically updated it from the entity related to the BPF, right? For example, update the boolean field on stage change event of the BPF (Javascript)

I have a workflow that triggers on active stage change event of the BPF entity. For example, I have a BPF with 4 stages: A, B, C and D. If the active stage is B, I check some fields and automatically move forward to the C stage or D stage (depends of the conditions). So I think the problem is when I update the active stage within that workflow.

The expected behavior is when user manually change the active stage (using BPF UI navigation), trigger the workflow, detects the active stage and do some stuff (e.g. jump forward to a next stage). If that so, it has to fire another workflow with the new active stage.

Reply
Bharat Premji responded on 19 Jun 2018 12:20 AM
My Badges

Hi Hugo,

No, I removed the workflows from the Stage entry and Exit completely.

The boolean field on the BPF is manually updated by user to Yes and then they can move to the Next stage (again manually)  

Not ideal but thats the only fix we could come up with at the time

Bharat

Reply
Sachith Vidanage responded on 13 Jun 2018 4:56 PM
My Badges
Suggested Answer

I guess your workflow is going through an infinite loop. When the new child incident created the workflow triggers and then again and again. CRM recognizes this and stops the loop; that's why you get only 3 records or a bit more without creating a lot. When a new child incident gets created probably the active stage changes and this causes the infinite loop I believe. Add extra condition (e.g. created on is more than a minute ago or so) before creating a child record which will stop the loop.

Reply
Sachith Vidanage responded on 14 Jun 2018 4:59 PM
My Badges
Suggested Answer

Try below for troubleshooting:

Enable auditing for the incident entity. (especially process stage field as this is the field which trigger the workflow)

Uncheck the checkbox which tells the system to delete the successful workflow instances.

Then you perform your activity and check the created incident records' audit log and workflow instances (system jobs). If you see any workflow instances for the child records we can confirm that above is the case.

Reply
Bharat Premji responded on 15 Jun 2018 2:18 AM
My Badges
Suggested Answer

Hi Hugo,

Do you have 3 stages in the BPF?

We have seen this behavior before where if the workflow is set to fire on the entry or exit of a BPF stage it fires the same number of times as there are stages in the BPF.

We got round this by adding a boolean field to the BPF and triggering the workflow from that.

I'm pretty sure this has been fixed in the Online version now

Regards

Bharat

Reply

SBX - Two Col Forum

SBX - Migrated JS