top of page

CRM 365 – Business Process Flow – Jump between stages

The moment when something stops to work without any changes of any type.

As it happened with me, i know it happened with many developers/customers more.

And as i got really annoyed more people got different feelings as well.

I will explain now what is the issue, in the opportunity entity it seemed the best for the client to use a Business Process Flow to help with a standard process, that is always a good idea, so that was developed against the Opportunity entity.

Everything was going great with the process, and then because of an exception we had to implement something that would allow to Jump from any stage to any stage, so, assuming the Business Process Flow had branches as well, thing could get more complicated. The solution was easy enough, implementing a "On Demand Process" that would change the Stage Id to the one necessary. Until that moment, everything was working with no issues.

However, at some stage, Microsoft just decided that the way the Business Process Flow was implemented was not the best/great, whatever….

What happened, or at least i understood from phone calls with Microsoft was, new tables were created for the purpose and a field "traversedpath" was about to become the Star of that.

Now let me explain what is the traversedpath. Traversedpath is a string field that contains all the guids of every stage until from the first until the current appended with the ‘,’ comma. Trying to be on the brilliant minds that came to that for me it makes sense, so, what’s the problem in here? Basically, opportunities created before the Update 9.0 (if i’m not mistaken).

Everything seemed to work apparently at the beginning, people creating new Opportunity records, and playing around the stages, and jumping sometimes from the first stage to the last one, everything seemed to work more or less.

But, when people started to play around old opportunities, things started to become a nightmare, and now, believe in me, when you have a CRM implementation with many opened opportunities and everybody started to complain about that, then you starting to fill mad(here i don’t want to put the name of my actual feeling, could be to strong).

What you do next, with no clue at all, you start to try things, to google and when you find that you not alone, you think, at least i’m not the only one, however, not me, i just thought, not again….

So Microsoft was called for that, and after few hours, something was becoming more clear, but even the code provided was not working 100% for the purpose, then i just tried few more things and i saw some improvements in the tests from the Test team and as well from the Client, scenarios were put on the table and tested in the Sandbox environment.

You can guess what happened, finally production environment was upgraded and then, with a full team of users using the system, more scenarios came into and more problems……

At that moment, and because is a Show Stopper, Microsoft was called again and few more experiences were tried, but at the end nothing conclusive, again i tried few more things and at the moment i believe that i’m really close to the end of the problems, but not 100% sure.

In the Custom Workflow Activity developed first thing done is getting the full path (all stages from the 1st until the current one) and update the opportunity before doing the actual jump of the stage. Below some code that can be seen as example:

Opportunity _opportunityToUpdate = new Opportunity(); _opportunityToUpdate.Id = opportunityId;

//all the guids should be appended in here from the 1st until the current stage _opportunityToUpdate.TraversedPath = traversedPath; _opportunityToUpdate.StageId = currentStageId; _opportunityToUpdate.ProcessId = process.WorkflowId; service.Update(_opportunityToUpdate);

I have tried to update the opportunity with the newStageId and the traversedpath to the new stage with no luck.

And then my solution, probably not the prettiest one, but it works:

Going one by one from the current until the one we need.

foreach (Guid stageId in stagesToUpdate) { Opportunity opportunityToUpdate = new Opportunity(); opportunityToUpdate.Id = op.Id; opportunityToUpdate.StageId = stageId; opportunityToUpdate.ProcessId = process.WorkflowId;

service.Update(opportunityToUpdate); }

Hope it helps.

5 views0 comments

Recent Posts

See All


bottom of page