Using Entity Reference Output Parameter in Workflow Assembly

By | March 15, 2017

Introduction:

Workflows in Dynamics CRM (now known as Process in Dynamics 365) allow users to create and manage automated business processes. It can be used to update entity records or related entity records. Using the OOB Workflow we can only update records which are accessible under the Workflow context.

If you want to update any other record which is not in the context of this workflow or not related to the record under which the Workflow is executed, then you need to write a custom assembly and update the record under the custom assembly.

There is an alternate way to update any record by using the same steps as you would follow to update the record using OOB workflow. It can be achieved by setting up the output parameter of the custom assembly.

Note: The output parameter type should be EntityReference.

Steps to update entity record by using custom assembly output parameter:

 1. Write a custom assembly and set the output parameter type as ‘EntityReference’ as shown in the code snippet. The Output parameter should point to the record that you want to update.

//Update Record by using Custom Assembly output parameter
accountRef = new EntityReference("account", new Guid("475B158C-541C-E511-80D3-3863BB347BA8"));
OutPutParameterName.SetValue(executionContext, accountRef);

 2. Create and Register a custom assembly on CRM environment then and create an OOB workflow.

 3. Now add a step to this OOB workflow and select the custom assembly that was created and registered in the above steps, as seen in the screenshot below;

Using Entity Reference Output Parameter in Workflow Assembly

 4. Now add a step ‘Update Record’ and click on the dropdown to select the Entity you want to update. You can also see a heading Entities Created By Steps and under this heading, you have a subheading to get the output parameter reference as seen in the screenshot below;

Using Entity Reference Output Parameter in Workflow Assembly

 5. Once you have selected the output parameter as shown in above screenshot, click on the ‘Set Properties’ button as seen in the screenshot below;

Using Entity Reference Output Parameter in Workflow Assembly 3

 6. Once you click on the button, a window is opened where you can set the fields you want to update. Click on ‘Save and Close’.

Using Entity Reference Output Parameter in Workflow Assembly

Conclusion:

By using entityreference output parameter in the custom assembly, you can easily update a record as you would do it with the OOB workflow functionality.

Cut short 90% of your manual work and repetitive data entry!

Get 1 Click apps and say goodbye to all repetitive data entry in CRM –
Click2Clone – Clone/Copy Dynamics 365 CRM records in 1 Click
Click2Export – Export Dynamics 365 CRM Report/CRM Views/Word/Excel template in 1 Click
Click2Undo – Undo & Restore Dynamics 365 CRM data in 1 Click