Editor’s Note: Visit this page to review Dan’s most recent blog post, Exciting New Ways to Execute Rules From Microsoft Dynamics 365.
Need to add more complex business logic to your workflows in Dynamics? Want to easily embed calls to InRule within workflows?
We did, too, which is why we built a simple InRule Workflow Activity plugin that allows you to easily integrate InRule into your Dynamics Processes.
Why use the InRule Workflow Activity instead of calling rules using the native InRule Custom Action plugin?
While you can call rules directly using the existing InRule Custom Action plugin from a workflow, doing this requires additional customization in Dynamics to add the target parameter (entity GUID) to the request, as well as custom code to parse the output.
By using the InRule Workflow Activity instead, the entity GUID is included in the call to InRule and we have more control over processing the output. Additionally, the InRule Workflow Activity provides access to the entire RuleExecution entity object, ultimately proving more flexibility for handling rule output in your workflows.
This InRule Workflow Activity is essentially a passthrough proxy to the default InRule Custom Action plugin, and has the exact same signature as the InRule Custom Action. The rule call works the same as any rule call in Dynamics, if fields are updated or entities are created in your rules and assuming persistChanges is set to the default of true, all changes will be reflected in Dynamics. However, since you have access to the entire RuleExecution entity object, you also have additional options to display messages in your workflow and to use Notification buckets to control your workflow. Here is an example of the Properties screen after adding the InRule Workflow Activity step in your workflow:
As stated above, with access to the RuleExecution object, we leverage the different Notification types to control the workflow path. Additionally, when working with Dialog workflows specifically, we have the ability to display success or failure messages to the end user.
In our own example rule app, we fire error notifications when the conditions are met to stop the workflow, and info notifications when the conditions are met to continue the workflow. However, you can use this output in any way you’d like to fit the requirements of your rule app and specific business problem, as you have access to Error Notifications, Info Notifications, Warning Notifications, and Validations and Errors (run-time). We just choose to only use the Error and Info Notification buckets in our example rule app.
In order to incorporate this in our workflow, after calling the InRule Workflow Activity, we check for the existence of data in Error Notifications or Info Notifications to stop or continue the workflow. Finally, there is the additional option to display the notification text in a dialog workflow using Prompt/Response, as well as the notification text in the Status Message in Dynamics when stopping the workflow. An example screenshot of using error notifications to stop the workflow is shown below:
Please email me for a copy of the plugin code and start making calls to InRule in your workflows and let us know what you think!
For more information on calling the InRule Custom Action please see the appendix in the InRule® for Microsoft Dynamics® CRM Integration Framework Technical Reference found in the Downloads section on the Support Site.