{Fix} Idiosyncrasies while dealing with Business Process flows in CRM 2013/ 2015.

Looking at the title of the topic, you must be thinking that I am going to discuss any bug in Business process flows. Well not exactly. However there are some situations where using business process flows can lead to confusing errors. Lets see such an example.

Let’s say you have a requirement where progression from one stage to another is dependent on some other factors. When the user tries to move to the next stage, there is some plugin or synchronous workflow which validates and throws a business process error. However when the user fixes the issues and tries to save the form, he keeps on getting the business process error although now all the entered values are correct. I have created a very simple set-up to simulate the situation.

In the example below, Stage 1 in the contact form has a Company field which needs to be filled if the user wants to move to Stage 2. I have created a synchronous workflow which throws a business process error if the user tries to change the stage without filling in the company field. Please check for the screenshots below.

image

 

image

 

Now without entering the company, we save the record and the contact is saved successfully.

Without the company name still not entered, Next stage button is clicked and as expected we get the following Business Process error.

image

Now even if we change something and try to save the record, we would keep getting this error. Why does this happen. Let’s explore.

When the form was saved for the first time, let’s query for the stageid field.

image

After we get the error, lets check for stageid on the form.

image

So as you can see, even though the record was not saved, the stage id field is holding the guid of the next stage and is in dirty stage.

So when you click save, this new stage id gets passed to the platform and hence we keep on getting the error.

So the solution to resolve this problem is to set the stageid back to the initial value when the form is about to be saved.

 

Hope this helps!

Advertisements

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s