I had a requirement where I needed to make certain fields on BPF as required.
So, I tried accessing the control using Xrm.Page.getControl(“header_process_description”) and then getAttribute().setRequiredLevel(“required”) on it would serve my purpose. But actually, not!
To set perspective, the code runs and make the field required too. But there’s a catch!
Required fields on the BPF are supposed to throw an error when you are trying to move to the next stage without filling in the required fields.
But, using the code I’m talking about above (sample shown below), will force you to save the form entirely. Let alone moving the stages further.
That when ‘How Did You Hear About Us?’ field has Employee Referral as value, make Purchase Process field required.
Field is on the BPF
But prompts me to save the form
The easiest workaround to this is using the conditional branching of your business process flow –
You can use conditional branching of the BPF itself – You can replicate the same stage twice, one having your required field and other having that same field as optional.
However, limitations I found with this approach is –
- I couldn’t use the same for the first stage of the BPF –
- The condition had to be from the previous stage itself
P.S. Business Rules isn’t a solution as well. Also, I tried to inverse the logic by first making the field required in the BPF itself and then trying to make it not required using code. That doesn’t work either.
Hope this gives an idea. Let me know if you have other suggestions! 😊