Skip to main content

Executing Dynamics 365 Rules from a Workflow Activity

If you need to run rules from a workflow, the solution provides a custom workflow activity that invokes the included custom action. The custom workflow activity passes in the entity ID and type automatically for you and provides the rest of the custom action settings as input fields on the activity. The activity also returns the details of the response as individual fields, instead of raw json. These are the fields returned:

  • Informational Notifications
  • Warning Notifications
  • Error Notifications
  • Validations
  • Errors

When using the custom workflow activity, you can select the option to throw an exception on failure. If you choose to throw an exception on failure, the workflow will end immediately if the custom action fails, and the user will see an error message if they are running the workflow synchronously. If you want to implement conditional logic to handle failures, you can disable this option and check for the existence of data in the Error return variable to determine if the activity failed.

If you don't want to use the default configuration for a particular entity, create a new InRule Configuration record according to Updating InRule Rules Configuration Records and then associate it with that entity by following Associating an InRule Configuration record to an Entity.

Additionally, if you want to run rules against multiple entities, you can leverage custom workflows from an entity view page and run the workflow against selected entities. This functions similarly to the entity view page Run Rules button, but the notable difference is that custom workflows allow for the execution of custom logic on the selected entities before the execution of rules.

warning

Before you can use the custom workflow activity, you will need to update the max plugin depth setting for the custom action step to be at least 2, instead of the default value of 1. This is because causing a plugin to be run from a workflow adds 1 to the current plugin depth. For more information on plugin depth, please refer to Changing the Max Plugin Depth