What happens when you force fields on BPF to be required programatically or using Business Rule

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.

jsCode

That when ‘How Did You Hear About Us?’ field has Employee Referral as value, make Purchase Process field required.

empoyeeReferalSet

Field is on the BPF

fieldOnBPF

But prompts me to save the form
promptToSave

 

Workaround

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.

bpfBranching

However, limitations I found with this approach is –

  1. I couldn’t use the same for the first stage of the BPF –
    limitation1
  2. The condition had to be from the previous stage itself
    limitation2

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! 😊

 

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s