Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Setting Output Parameters in Plugins for Custom Actions

Post Author: Joe D365 |

Actions in CRM can reduce manual workloads and give developers a trigger point to lead into custom development. These can be called from Workflows, JavaScript, plugins, and custom Workflows. We can pass the Input parameters to the custom Action and the results can be set as Output parameters. Actions can be called from buttons in CRM using JavaScript. In today's blog, we'll show you how this all works and the steps needed. Let's dive in!

Output Parameters can be set via a Plugin. We call an Action from a Workflow. Additionally, the Input parameters can be set and accessed from the context in the plugin.

Now let's see how to set the Output parameters from the plugin using the steps below:

1. First, access the Input parameters in the plugin of the custom Action.

EntityReference recordEntRef = (EntityReference)context.InputParameters["Record"];

2. Set the Input parameter "Record" with the data type of Entity Reference.

3. Set the Output parameters in the plugin for the Action.

context.OutputParameters["OutputParameter"] = returnRecords.Entities[0].GetAttributeValue<EntityReference>("assigneduserid").Name.ToString();

"OutputParameter" is the output parameter data type as Entity Reference.

If the Output parameter is set in the plugin for the custom Action, then it should be registered on Post-Operation. If the step is registered as Pre-Validation or as Pre-Operation, then the Output parameters will always be null even if we try to set them in the plugin.

Setting Output Parameters in Plugins for Custom Actions

If the Output parameter gets back a response, it can be processed for further use.

var actionResponse = (OrganizationResponse) service.Execute( actionrequest );


if (actionResponse.Results.Contains( "OutputParameter" ) )


return actionResponse.Results[ "OutputParameter" ];

Want to get handy CRM tips and tricks like this one delivered directly to your inbox? Subscribe to our blog today!

Happy CRM'ing!


Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

5 comments on “Setting Output Parameters in Plugins for Custom Actions”

  1. When I try to have 2 Output EntityReference I always got an error.
    When I try to have 1 Output EntityReference, and I do a webapi call in the response I receive a key contactid, value the guid of my entity reference instead of "OutputParameter": {my entityreference object}

    Any idea how to get 2 Output EntityReference? I tried with same type or different types I always have an error when I execute the action via the webapi.

  2. Hey I want to retrieve value of lookup from one entity to another. On Pre-operation
    Can I get the value of lookup field after saving record ? I m getting value of string, whole number problem with only lookup.

PowerObjects Recommends