We are introducing a simple declarative interface to help you implement and maintain your fast changing, commonly used business rules. The rules will be applied to Main and Quick Create forms for the web application, Outlook and CRM for Tablets.Thats why we call them Portable.
Business rules are designed to allow you - even if you have no programming experience - to create client side scripting to run on forms. You will use a business rule editor to create and modify these Business Rules through the UI (Solution Explorer: Settings -> Customizations -> Customize the system -> [ENTITY] -> Business Rules)The code behind the rules you create in the editor are bound by the client SDK and this will help reduce unsupported client customizations. Also, they are built on top of workflow infrastructure.
Conditions and Actions
Business rules consist of a collection of conditions and actions that can be used to enforce simple business logic of an organization.Conditions consist of a field, operator and operand (value, type or expression) that make up a logical statement that evaluates to true or false. If all the conditions of a rule evaluate to true, then the actions are executed.
What you can do with Actions
A subset of the capabilities provided by form scripts are available via the following Actions:
Validate data and show error message rules
Show or Hide a field rules
Enable or disable field rules
Set field value rules
Set field requirement rules
To add a condition, click the "+" icon and a new condition row will appear with default values set. Type in the field name to set the Field and then choose the appropriate Operator (see later). Operator options will change depending on the data type of the field.
You can chose three different types of conditions:
When you are finished entering or editing the rule, click the check mark icon to save it or the (X) icon to remove it.
To illustrate the above I've created an example. In this example I create an entity ("Showcase") with the sole purpose of helping me do automatic calculations if I so choose.
If I pick Yes in a custom two option field "DoTheMath" my Business Rule will add the value I write in a custom whole number field "FirstInteger" to the value I write a custom whole number field "SecondInteger" and place the result in a custom field "Result".
The defailt view for my new entity I call "Calculations"
Fig 1: Two records, note the last record in which my rule has done the math for me
Fig 2: I expose the new entity in the UI
How its set up
I create a custom entity, and I select where I want to access it from - which modules in CRM
Fig 3: The entity is available to me from several modules
I also want to expose the entity in CRM for Tablets as well (see later) so I check the "CRM for Tablets" checkbox under the "Outlook and Mobile" section
Fig 4: Important to check the "CRM for Tablets" to expose the entity there
I create four fields
Fig 5: Four custom fields to my entity
I create a view with four extra columns corresponding to the four custom fields
Fig 6: custom view
I modify the main form to accomodate the custom fields
Fig 7: modified form
I add a new Business Rule using the "Business Rules" entry in the sitemap and the "New" button
Fig 8: Business Rules for my entity
My business rule "Calc This" is setup according to the screenshot below - if I have a "Yes" in the "DoTheMath" field AND values in the "FirstInteger" and "SecondInteger" fields, the rule will do the calculation for me
Fig 9: conditions and action in the business rule
Note that when I pick the "DoTheMath" field in field chooser to the left in the editor, and "Value" in the "Type" chooser, the "Yes/No" values corresponding to the type for the "DoTheMath" field is automatically made available in the condition
Fig 10: building the first part of the condition
I also want the "FirstInteger" and "SecondInteger" fields to contain data before calculations are done
Fig 11: adding AND conditions
Moving on to the Actions.
My rule should set the value of the field "Result", using a Formula ("FirstInteger" PLUS "SecondInteger").
First I pick "Result" in the Field chooser. Then I pick Formula in the Type chooser, to reveal a formula building block right below the Field/Type choosers.
In the formula building block I pick the field "FirstInteger", then the operator "+" and the type Field, which lets me pick the "SecondInteger" field in the lower rightmost Field chooser
Fig 12: Formula building block
I activate the rule and I'm ready to test the rule (remember to Activate - otherwise it won't fire)
Testing the rule, I pick "Yes" in the "DoTheMath" field and input numbers in the "FirstInteger" and "SecondInteger" field.
Fig 13: Testing the rule
If all conditions are met, the moment I click in any field (change focus) the rule will perform its action
Fig 14: The rule have fired as expected
If I pick "No" in the "DoTheMath" field, the rule shall do nothing (note: at this point you probably want to do more, eg. hide/clear the "Result" field - see how in this additional example)
Fig 15: No means no calculation
So the rule works as expected in the web client.
Remember I ticked the "CRM for Tablets" checkbox when I created the "Showcase" entity? I did that because I really like my new CRM for Tablets app, and I'd like to leverage my new entity "Showcase", including the business rule, in that app as well.
The default view in the CRM for Tablet app is the "Sales Dasboard", displaying six components ("My Activities", "My Open Opportunities" a.s.o)
Fig 16: Sales Dashboard in CRM for Tablets
In order to see my "Showcase" entity in the dashboard I'm going to replace the Lead component with my "Showcase" component.
To edit the "Sales Dashboard" shown in the CRM for Tablets I must go to the web client and customize the system dashboard "Sales Dashboard".
Fig 17: editiing the Sales Dashboard
The "Sales Dashboard" has the same limitations as all other Dashboards, including a limit of 6 components. I cannot 'just' add another component for my entity, so I click the component I want to edit (the component currently displaying "My Open Leads")
Fig 18: the component to edit is selected
I point the component to my custom "Showcase" entity
Fig 19: pointing the component to my custom entity
I check to see the changes has been saved and Publish
Fig 20: changes are saved
Next time I open my CRM for Tablets the server side configurations are downloaded and I now have my entity "Showcase" available to me in CRM for Tablets as well
Fig 21: Sales Dashboard now displays my entity
I can now create new records of the "Showcase" type using the Commandbar button New Record (to display the commandbar on tablet I swipe up from the bottom of the screen - or rightclick if using a mouse)
Fig 22: the 'New Record' button in Commandbar displays list of available entities, including my new entity
And sure enough (thats why we call it portable business logic) my rule works as expected in CRM for Tablets too
Fig 23: creating record
Fig 24: input values
Fig 25: business rule fired
I hope you agree with me that the Business Rules is a powerful addition to CRM for non-programmers - and I encourage you to give it a try yourself. You can easily create a 30 day free trial and give it a go. The CRM for Tablets app is free for licensed CRM users, and ready for you as well in selected online stores.
You might also want to check out the addition to this example - "Using Multiple Business Rules" to implement If-Then-Else logic (and some simple housekeeping).
Great write up. I would like to see Remove Value as a PBL option for all field types, as you may have a user click 'yes' (perform the calculation), only to realize that the circumstances require 'no' (don't perform the calculation). Now you are left with an inappropriately calculated field value.
Please see: blogs.technet.com/.../crm-2013-extending-business-rules.aspx
Any limitation with number of Business rules we can have per CRM Organization?