Call a workflow on Stage Exit of a last stage in business process flow of Dynamics 365 CE

By | April 16, 2019

Introduction

As Dynamics 365 CRM’s native feature, we can call on-demand workflows from inside a business process flow. We can configure this from the new business process flow designer, by dragging a workflow component to a process stage, or to the Global Workflows section.

As you know, we have written a blog on global workflow where we can find its basic information. In this blog, we are continuing this by exploring global workflow with detailed steps.

An on-demand workflow from inside a business process flow executes as usual on Stage Exit of a stage but it does not work, if we call on-demand workflow from on stage exit of a last stage of business process flow.

When we include a workflow that we want to trigger on Stage Exit of a stage in business process flow, and that stage is the last stage in the flow, the designer gives the impression that the workflow will be triggered when that stage is completed. However, the workflow will not be triggered because a stage transition does not take place when BPF is finishing from last stage and not moving to previous stage. We will not receive a warning or error preventing us from including the workflow on that stage. When a user interacts with the business process flow, finishing or abandoning the process does not result in a stage transition, and therefore, the workflow is not triggered.

Consider the following examples:

  • We create a business process flow with two stages, “Identify” connects to “Research,” with a workflow on stage “Research,” and set the trigger to Stage Exit.
  • We create a business process flow with three stages, “Identify” connects to “Research,” then “Research” branches to “Resolve.” We include a workflow on “Research” and set the trigger to Stage Exit. When condition does not match, then stage does not move to “Resolve.”

The workflow will not trigger in either case.

As shown in below screen shot, on demand workflow on stage “Research,” does not trigger on stage exit, when we click Finish button. My on demand workflow sets the value of Remark field on stage exit of “Research” stage.business process flow of Dynamics 365 CE

To work around this issue, we have added a Global Workflow, and added the workflow which we want to trigger to it so that the workflow is triggered for the business process rather than a stage of the process.

business process flow of Dynamics 365 CE

After updating the BPF, as shown in above image, reload the form and click “Finish” button on BPF, and last stage is “Research.” Now workflow triggered as expected.

business process flow of Dynamics 365 CE

Also, we can set the trigger for a Global workflow to Process Abandoned or Process Completed to cause the workflow to trigger when a user abandons or completes the business process.

Conclusion

An on-demand workflow from inside a business process flow executes as usual on Stage Exit of a stage. However, it does not work if we call on-demand workflow from stage exit of a last stage of business process flow and finish the business process. For this we need to set the trigger for the Global workflow to Process Completed to cause the workflow to trigger when a user completes the business process.

Leave a Reply

Your email address will not be published. Required fields are marked *