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
- Access the BPF record via advanced Find
- delete the invalid stage you deleted previously.
- Save It.
Tada (firework) User is able to move to previous stage after the Traversed Path is corrected.
Programtically using code
- First grab all the BPF records.
- Split the traversed path into single string into an array.
- Loop Through the string, and pass into the below query.
- if the result is 0.
- 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.
Great post. Thanks very much!
ReplyDeleteWe 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!
Found an easy way that may work for some- System Administrators can Reactivate a Business Process Flow:
ReplyDeleteIn 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.