The main message is that input/output arguments are available in the InputParameters/OutputParameters’ collections of PluginExecutionContext.
Usage of Input argument
The following code shows how to check that the Input Argument was passed and got value:
if (localContext.PluginExecutionContext.InputParameters.Contains("ArgumentName")) { string stringInputArgument = (string)localContext.PluginExecutionContext.InputParameters["ArgumentName"]; } else { //Your code for case when Argument was not passed }
Usage of Output Argument
The following code shows how to set the Output argument:
localContext.PluginExecutionContext.OutputParameters["OutputArgumentName"] = <Value>;
One thing you should remember is that step that handles your action and sets Output arguments has to be registered on Post Operation (40).
For those who use the CRM Developer Toolkit registration of new plugin, registration of your step in code of your plugin and part of RegisterFile.crmregister file is:
base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(40, "MessageName", null, new Action<LocalPluginContext>(PluginClass)));
<Step CustomConfiguration="" Name="StepName" Description="Description" Id="024c3b93-6041-e311-ad38-6c3be5a8d218" MessageName="MessageName" Mode="Synchronous" PrimaryEntityName="none" Rank="1" SecureConfiguration="" Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly">
Hello Andrii,
I wonder why “step that handles my action and sets Output arguments has to be registered on Post Operation (40).”? There is a good reason?
And does that means we should use sevice Update in order to update the trigger record?
Thank you
Moshe, I would love to get an explanation as well but I believe this is how it was built and designed. Yes, that will mean that you will have to use Update and explanation is really easy – you have not only bound Actions. You have unbound as well. What entity do you want to work with when you use undound action?
Can I use the output parameter in action steps, after I set the output parameter in the plugin call?
Ashar, I’m afraid that no because you can set values only in post-operation plugin and all the process logic is executed in “core”-30 operation.