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.
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.
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.
After we get the error, lets check for stageid on the form.
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!
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.