Business logic can be applied to Dynamics CRM by a combination of these processes:
  1. OOB workflows
  2. Custom workflows
  1. Plugins
  2. JavaScript

Other than the OOB workflows (which has its constraints), the rest involve some knowledge of coding, with the plugins and workflows requiring background in C#. So if there is new requirement to create a business rule, typically the request is submitted to the IT/ Development team, and depending on their schedule the rule is created. If the rule needs changing, the business user needs to again reach out to someone outside of his/ her department.

Now consider a situation where the Business user has complete control of creating the rules, using an interface that is easy and intuitive to use. This is where InRule® for Microsoft Dynamics® CRM  comes into the picture. InRule is a business rule management system (BRMS) that separates decision logic from application code and provides a relatively easy way to create and update rules. InRule for Microsoft Dynamics CRM provides additional components to enable creation and update of rules within Microsoft Dynamics CRM. 


InRule for Microsoft Dynamics CRM leverages InRule’s rule authoring component, irAuthor®, and its execution engine irServer®. It also includes irX for CRM, a patent-pending extension to irAuthor that provides the ability to author, update, and test rules for use within Dynamics CRM. The offering also includes InRule Technology’s implementation guide for prescriptive guidance using rules with CRM.

There is some effort that goes into hooking up the rules to CRM, but more often than not it is a one time process to set up the link.

The guts of the InRule BRMS is the irAuthor rules engine. Once the rules engine is in place, the Dynamics CRM extension is installed on top of it. irAuthor CRM extension uses the CRM webservices to read CRM data and metadata. The rules that are created using the CRM fields are then fired in 2 ways:
By a create, delete or update custom code plugin
By Javascript calling webservice to effect instant data validations and calculations

In this post I will walk through a sample case to create a rule on the CRM account entity using InRule. I used a CRM admin with the InRule CRM extension, but if using other users the following are the minimum permissions needed on the CRM system:
Business Management Tab
User Settings: Read - User

Customizations Tab:
Entity: Read - Organization
Field: Read - Organization
Relationship: Read - Organization
View: Read - Organization

Business Case:
Create a rule using InRule® for Microsoft Dynamics® CRM on the Account entity that sets the credit limit as a function of the annual revenue if the form data passes certain criteria.

Install and Configure irAuthor:
 Install the irAuthor rules engine first using the msi provided. Once the rules engine is in place, the Dynamics CRM extension is installed on top of it.

Open irAuthor and go to File/ Options/ Microsoft Dynamics CRM Environments to add multiple orgs to the InRule setup. You will need the organization service url from Settings/ Developer resources in the crm environment.
























Create new Rule:

1. In irAuthor, select the CRM tab, click on create new CRM Rules button and choose the environment you want to connect to. Provide the credentials to sign in to CRM























    2. You will now see a dialog which shows the list of all entities and fields available in the CRM system. For this test case, I have chosen the Account entity and selected the following fields as shown in the screenshot. Notice the nice filtering capabilities on entity and field level. It was also very convenient to have the "Show only selected" checkbox. Lookup fields and children (one-to-many relationships) in the system can also be selected, if needed.




    3. Select the Account entity and click on the "Create Rules" link on the right.


























    4. Enter a name for the rule, and make sure it is enabled. In the Child Rules section, add a new rule of type "Language Rule"






      5. In the Language Rule section, click on the "Create Rule" link. A drop down with multiple choices shows up. Select an "If… Then … Else.." Rule.






      6. Create a Rule as shown in the screenshot. A couple of nice things that I want to point out:

      1.  The pick list text values are available, so you don't need to guess what value corresponds to what text.
      • Multiple arithmetic operations are available to modify the credit limit value. In my case, I am using percentage of the annual revenue.




      7. Save the rule either to the file system or to the InRule Catalog.

      Test the Rule:

      1. Click on the Test button on the CRM tab. Note the list of account views that show up. If you want to point to a different CRM environment, select from the list of environments that have been configured.

























        2. Select a record from the list and click ok.

        3. The irVerify dialog contains the list of Account fields selected. Changes to the fields can be made to make them pass or fail the rule defined earlier.

        4. Click on the "Apply Rules" button on the ribbon. In our case, the rule criteria is going to fail, thus setting the credit limit to 90% of the annual revenue.



























        Deploy the Rule:

        The rules can be deployed to the CRM system by 2 ways:
        By a create, delete or update custom code plugin that calls the InRule rule file created above
        Using Javascript to invoke a custom web service application to call the rule file.

        Details are provided in the sample project and white paper documentation from InRule. For the purposes of brevity and time, I will not be going over them in this post.

        The nice thing about the deploy type is that the rule itself is abstracted from the way it is being called by CRM. So any changes or updates to the rule are picked up instantaneously by the system. Very cool!

        Conclusion:

        The outline here has just scratched the surface of InRule® for Microsoft Dynamics® CRM. The platform is very robust and extensible, and I can see a number of uses for it. It gives the control of rule authoring back to the Business Analyst, while providing them with more than enough features and options to be successful. If you are in the market for a Rules engine to work with Dynamics CRM or if you just want to reduce coding for tasks like form validations, pricing, promotions, routing and calculations, you should check it out!

        One additional piece that has me impressed is irVerify. Rules created can be tested with data in the CRM system, with all the system views visible to the user. There is also an option to set a regression test suite too.

        I do have a couple of suggestions/ issues when using irAuthor:
        1. The CRM extension for irAuthor kept giving me a license expired error. Uninstalling and installing the extension fixed the issue each time. Note that I was using a one month trial license.
        1. It would be nice to have the sample plugin already compiled and part of a managed solution in CRM. So the crm user will just need to add Step (on what action and entity the plugin will fire) and the Image sections using the plugin registration tool.
        1. Similarly, an admin tool to automate creating a web service with values from a form would be useful.

        A couple of disclaimers before I bid adieu
        1. For the latest product and licensing information, please contact InRule directly.
        1. I have tried the Rule authoring in my demo VM, and have not used it extensively outside of it or deployed it to production.