Featured Post

Dynamics 365 - Business Process Flow and Things to take note before you upgrade into Dynamics 365.

In 2 months ago, my company decided to upgrade the Dynamics CRM 2016 into Dynamics 365 and there is something different about Dynamics 365 B...

Saturday, October 28, 2017

Dynamics 365 - Hit error when trying move to previous stage


Every few months, we received such requirement  "management decided to remove one of the stage" again. But after delete the stage, an error pop up  when users were trying to move to previous stage.

Why is this happening ?

DEMO

In this demo,  the BPF has 4 stages ( Qualify,Develop, Propose and Close) and Management decided to delete the stage "Develop".

1. Delete the Stage "Develop" from BPF.
2. Current Stage is "Propose".



3. Everything seems fine. But where the time user is trying to move to previous stage, they hit an error and without much useful information provided.



Root Caused

The traversedPath is not correct. it seems that when we deleted the stage, the CRM system will not update the traversedPath.

Solution

  1. Access the BPF record via advanced Find 
  2. delete the invalid stage you deleted previously.
  3. Save It.



Tada (firework) User is able to move to previous stage after the Traversed Path is corrected.



Programtically using code

  1. First grab all the BPF records.
  2. Split the traversed path into single string into an array.
  3. Loop Through the string, and pass into the below query.
  4. if the result is 0.
  5. remove the stageid from Traversed Path and update it.

     private int CheckisstageExist(string stageid)
        {         
            var fetchxml = "<fetch version='1.0' output-format='xml-platform' mapping='logical'              distinct='false'>"+
                              "<entity name='processstage'>"+
                                "<attribute name='processstageid' />"+
                                "<attribute name='stagename' />"+
                                "<attribute name='stagename' />   "+     
                                "<filter type='and'>"+
                                  "<condition attribute='processstageid' operator='not-null' />"+
                                  "<condition attribute='processstageid' operator='eq' value = '"+stageid+"'  />" +
                                "</filter>  "+
                              "</entity>" +
                            "</fetch>";

            EntityCollection result = m_service.RetrieveMultiple(new FetchExpression(fetchxml));

            return result.Entities.Count;
            
        }


I hope this will help you to save some time and Happy CRM-ing.


2 comments:

  1. Great post. Thanks very much!

    We had to update manually 200 BPF because we can't update the "Taversed Path" field via Export/Import or using a workflow...

    It seems like a flaw to us, but at least there is a solution!

    ReplyDelete
  2. Found an easy way that may work for some- System Administrators can Reactivate a Business Process Flow:
    In the ellipses on the form You can go to Process and Reactivate, it will set it back and you can move to the correct step.

    ReplyDelete