Working with Workflow and Workflow Assembly Output Parameters

By | September 21, 2018

Introduction:

Using the OOB Workflow, you can use values that are only accessible under the Workflow context to perform operations. If you want to use values that are not under the context of the Workflow or not related to the entity record for which the Workflow is going be executed, then you will need to write a custom assembly that will retrieve the output parameter.

As shown in the below code snippet, you can write a custom assembly to retrieve values through the output parameters as required;

//Refference of account record
EntityReference refContact = new EntityReference ( "contact" , new Guid ( "2C97F902-555F-E811-A97F-000D3A370EF7" ));
setContact.Set(context, refContact);
 
//Refference of contact record
EntityReference refAccount = new EntityReference ( "account" , new Guid ( "9297F902-555F-E811-A97F-000D3A370EF7" ));
setParentAccount.Set(context, refAccount);
 
//Optionset value
setPurchaseProcess.Set(context, new OptionSetValue (2));
 
//Money field value
setBudgetAmount.Set(context, 25000);

While setting the values using custom assembly, you can see that there are multiple local values of one custom assembly.

Working with Workflow and Workflow Assembly Output Parameters

For example,

1. “Custom_Parameters” attribute contains retrieved output parameters other than entity reference type parameters.

Working with Workflow and Workflow Assembly Output Parameters

2. “Custom_Parameters:setParentAccount (Account) contains all the attributes of the referred Account record.

Working with Workflow and Workflow Assembly Output Parameters

3. Custom_Parameters:setContact (Contact)” contains all the attributes of the referred Contact record.

Working with Workflow and Workflow Assembly Output Parameters

Note: setParentAccount and setContactis are the variables that are defined in the Workflow Assembly, and Account & Contact are the respective targets

This way, you can use any attribute value of the referred account or contact or any other entity to perform operations.

Conclusion: 

Instead of using multiple output parameters to retrieve values from one record, use entity reference of that record as an output parameter, and get access to all its attributes to perform operations.

Export Dynamics CRM Reports