Business Rules with Dynamics CRM 2013 Composite Controls

Posted: October 23, 2013 in Dynamics CRM 2013

In my last posts I introduced Composite Controls in Dynamics CRM 2011, and described how JavaScript works with fields inside the controls, including a few limitations. In this post I wanted to see how we can use Business Rules on fields in the fly-out menu. I will put to test all 5 ‘actions’ we can perform with Business Rules, and see if the results are any different to JavaScript.

1. Show error message using Business Rules

We can add some validation to a field inside the fly-out menu, the red ‘X’ will appear next to the composite field. If we display multiple error messages, for example on Street 1 and 2, only 1 ‘X’ will appear beside the composite field.

2. Set field value using Business Rules

Just like with the JavaScript, this sets the value inside the fly-out menu, but doesn’t update the composite field until you click in and out of the field, or save the form. Note: we can also ‘get’ the value of fields in the fly-out menu from Business Rules when setting another field on the form.

3. Set business required using Business Rules

This one works as expected with no issues, same as the JavaScript.

4. Set visibility using Business Rules

We could do this using JavaScript, but it was using an unsupported method. I’m happy to see that this does work with Business Rules. You can see here I have a business rule with no condition (so it always fires) with an action that hides the Address 1: State/Province field. The result is that the field is completely hidden from the fly-out menu.

This works better than the JavaScript approach, and is supported too.

5. Lock or unlock field using Business Rules

This one was not possible using JavaScript, because we couldn’t access the ‘control’. Fortunately we can do this using Business Rules. You can see below the Street 2 field has been locked (disabled) inside the fly-out menu.

It looks like all the Business Rules work just fine with the fields in the fly-out menus, except for maybe the set value issue, which will hopefully be fixed in a future update. Other than that though, this provides us a supported way of hiding fields, and locking/disabling fields in fly-out menus, where it was otherwise not possible or not supported using JavaScript.

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 )

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