In CRM 2013 Microsoft introduced many more interesting
features one of them being Business Rules. Business Rules is a way to provide
custom business logic through a simple to use UI and eliminate the need to write
scripts to handle such UI driven business logic. Examples of such business
logic includes enable/disable or show/hide logic or business required or set
the value of one field based on the value entered by user in another field.
How to create Business Rules in CRM 2013
- The ability to add Business rules has been included as a part of the entity design and can be handled from the Entity customization screen.
Once you click on “New Business
Rule” it will open following window.
Let us look at each of the fields available on this screen.
Scope: Using scope
you can define the Forms that you would like to apply the business logic on.
You can choose a single or all forms to apply this business rule on.
Name: Provide a
descriptive name for the rule.
Conditions: In
this section you can specify the conditions if any to check. You can provide
multiple conditions and currently all conditions are combined using “AND”. It
does not provide support for “OR”.
- Field : Select the Field for comparison. This will list out all the fields from selected entity.
- Type : it allow us to specify the type of data with which comparison should be done. It has options as Field and Value as shown below.
- Field : if you select type as field it allows to do comparison with another field on the same entity as shown below. It will only allow for comparison between fields of the same data type.
- Value : if you select type as value it will allow you to enter the value to be compared with. Depending on the data type of the field selected you will be allowed to enter the values.
Once condition is set click on tick mark button as shown
above so it will save the condition.
Now as you can see in below example we have set Business
Rule name as “Account number required” and condition as “If
Relationship Type equals Customer” and “Account Number does not contain data”
Going further after specifying condition now set the action need to be
performed when condition is true.
Action : it allows us to set the actions which will
get triggered when condition is true.
1. Show error message: if condition is true
and if you set action as “Show error message” it will show/throw error. Here
you can select the field on which you would like to set error message and give
specific error message. And save those changes.
It will show error as follows.
2. Set field value: if condition is true and
if you set action as “Set field value” it will set specific field to default
field value or to another field value. This could be used in scenarios where
the Probability % is driven by the sales stages on opportunity.
Note: consider for each condition you need to create different Business Rule. then only it will set different values for different sales stages.
It will set value as
follow.
It will set field business
required as follow. Once you select Relationship type as “Customer”, it will
set Account Number as Business Required.
4. Set visibility: if condition is true and
if you set action as “Set visibility” it will either hide the field or show the
field on form. As shown below select field for which you would like to set
visibility then select the status of field either “Show field” or “Hide
field”. And save those changes.
By default it will show Account number field on
account form but once you select relationship type as Customer it will get hide
as shown below.
By default the Account number field
is Unlocked but once you select Relationship type as customer, the Account
number field get Locked as shown below.
Note: There is no way to provide for an “Else”
condition right now. So if you would like the action to differ when the
relation type is “Customer” and when it is something else, you need to create
another rule for the else condition. If another rule is not created and you
change the value of the relation type from Customer to something else, the
error being displayed on Account number would not be immediately refreshed
similar to onchange scripts written with if.. else condition to handle
immediate updates.
After this you can specify the Description about the
rule as shown in below screen shot. Click on save and Activate the Rule.
Once you click on Activate button it will prompt for Process
Activate Confirmation window here select Activate.
Once Rule is activated its status is changed from draft to
Activated as shown below.
Note :
1) consider whenever you require to do changes in rule
you need to first deactivate it and then do the changes, save those changes and
Activate that rule again.
2) Business rules being a part of entity customization
can be shipped along with the entity.
3) Since the tablet UI is rendered based on the entity
forms defined, the business rules would also be applied on Tablet devices.
Conclusion
The question as always is within MS CRM: What about multi language support for those error messages. I could not find any occurrence where I can specify the language code so far.
ReplyDeleteMichael
nice one...
ReplyDeleteI have create the business rules as shown above but ,on form error shows please activate business rules.what to do?
ReplyDeletehow to set null value to the attribute using business rules?
ReplyDeleteThe current design of Business Rules prevents setting of null values. This feature request is being tracked in connect. You may want to vote for it at https://connect.microsoft.com/site687/feedback/details/798202/business-rules-ability-to-set-the-value-of-a-field-to-clear. Need to have permissions to this site.
DeleteAfter creating business rule it is necessary to "Activate" that rule then only it will get executed. So you need to first confirm that you have activated the rule as also described in this blog.
ReplyDeleteyes.i activated the rule as shown in this blog and publish all.But problem still there.
DeleteWere you able to resolve the issue? Apart from activating the business rules there is no other specific action required. You may want to close and re-open the form to load the updated rules.
ReplyDelete