Business Rules within Microsoft Dynamics CRM 2013 allows users to add functionality to the system that in previous versions of Dynamics CRM required development. Previously, JavaScript would be used to hide fields and tabs on forms in order to only present users with relevant fields. Now with Business Rules, fields can be hidden and shown without adding code. Business Rules cannot be used to show and hide a tab but can be used to mimic that functionality by showing and hiding a section. When the fields in a form are all hidden the section will also be hidden.
Here are the steps to implement this functionality.
- Navigate to Settings -> Customizations -> Customize the System. Open the entity form that needs to be customized.
- Under the Insert Tab, select the Section button and add a one column section.
- Next, click on the section and then using the field explorer, double click fields to add them to the section.
- Select each field that was added and click the Change Properties from the ribbon. In the field properties window, uncheck the box for “Visible by default” and make sure the box is checked for “Display label on form”. Click OK. This will default the fields to hidden.
- Select the section, click Change Properties from the ribbon and then give the section a meaningful name and label for that grouping of fields. Check the boxes next to “Show the label of this section on the Form” and “Show a line at the top of the section.” Uncheck the box under Visibility for “Visible by default.” Click OK. This will default the section to hidden.
- Save and Publish the changes to the form.
Next Business Rules need to be created to show and hide those fields based upon a specific condition. In this example, the condition for showing the fields will be when Account Type is equal to Type 1.
- From the form, click the Business Rules button on the ribbon.
- Click New Business Rule at the bottom of the Business Rules Explorer. A new window will open.
- Give the Business Rule a descriptive name.
- Under the Condition area, click the plus sign. Select “Account Type” under Field (or the field being used for the show/hide condition), select “Equals” under Operator, select “Value” under Type and choose the correct value. Then click the green check mark to add the condition.
- Under the Action area, click the plus sign and select “Set Visibility.” Select the field that need to be shown and select “Show Field” under Status. Then click the blue check mark to add the action. Repeat this until all the fields that need to be shown are added.
- Add a description for the Business Rule.
- At the top of the window click Save and click Activate.
A Business Rule needs to be added as well for when the condition is not met and the fields should be hidden.
- Click Save As from the top of the Business Rule window. The system will create a copy of the Business Rule.
- In the new Business Rule, update the name of the Business Rule, update the Condition operator to “Does Not Equal”, update the field visibilities under Action to statuses of “Hide Field” and update the description.
- When finished, Save and Activate the second business rule. Close the business rules.
- Save and Publish the form.
Now let’s test!
Navigate to a record with the customizations and Business Rules. By default, when you open the record, the fields and the section should be hidden. Change Account Type to “Type 1” to trigger the show fields Business Rule. The recently added fields and the section will appear. Change Account Type to “Type 2” to trigger the hide Business Rule. The fields and the section will hide.
If you want to know more about Business Rules in Microsoft Dynamics CRM 2013, read our blog titled, “Why business rules are the biggest change to Microsoft Dynamics CRM 2013.” If you want more information on Microsoft Dynamics CRM 2013, RSM offers a full range of services from implementation and optimization to development and support. Contact our professionals for more information at 855.437.7202 or crm@mcgladrey.com.
By: Alesha Baerenwald – Microsoft Dynamics CRM partner in Minnesota