As we already know, Actions are very powerful components that can be leveraged within Dynamics 365. Today's blog will give you quick tips on how Actions can be utilized. Let's jump right in…
Actions can be used to avoid custom coding (plugins or custom workflows).
Accessing data that is specific to a lookup (relationship) on an entity using the out-of-the-box workflows does not work on its own. But with actions, is completely possible.
Scenario: On Update of Account you have the check if the related Primary Contact's custom lookup's (an address record) state field is "WA" and populate that on the Account entity. This relation has a greater depth that cannot be reached with just a workflow.
- Create a custom action, None (global), with an Entity Reference Input Parameter for Address entity and an Entity Reference to the Account Entity
- Within the custom action, add a check condition to verify the Input Address has the state as "WA" and if that is true then update the state on the Account using the Account Input Parameter
- Create a workflow that triggers on Update of Account entity
- Select the Perform Action and pass the Address lookup from the Contact which can be accessed from the related records of the Account entity
- And pass the account record itself as the second Input Parameter
Activate both the processes. Now create dummy data to verify this process. Go ahead and trigger the Update which will run the workflow record, the workflow will pass the Address from the Contact record and the account record to the custom action. The custom action will now process the logic since it already has the address lookup in it, if the state is "WA" the next step will be to update that on the Account record using the second input parameter.
The Input parameters on the custom action can be made as required so that there is validation when the workflow calls it. This scenario would have lead into a custom code component if we did not have the custom action. Below you will find the screen shots of the Workflow and the Custom Action.
Note: You can always add extra conditions to check if the field contains data in order to avoid null exceptions(object reference exceptions)
Workflow screen shots:
The first screenshot explains the setup of the workflow and the second is how to pass the data to the action.
Action Screen Shots:
The first screenshot is the setup of the custom action. Second and third screenshots just show the detailed definitions of the Input Parameters.
As always for any CRM questions you can reach out to the PowerObjects team by clicking here.