web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin Output Parameters

(0) ShareShare
ReportReport
Posted on by

In the example code given by microsoft in followup plugin (link below)

https://msdn.microsoft.com/en-us/library/gg594416.aspx

there is a code line which tries to attach account as regardingobject to the task which will be created.

Guid regardingobjectid = new Guid(context.OutputParameters["id"].ToString());

Why is that Output parameters are used to get the ID of the initiating entity when you can
get it easily by entity.Id from Target.

Thanks.


*This post is locked for comments

I have the same question (0)
  • TomSmelser Profile Picture
    1,570 on at
    RE: Plugin Output Parameters

    Bhanu,

    Not sure without testing, but because this is a plug-in to be executed on create of account, it's possible the id would not exist yet. The create output is a new account with an id.  If this were a workflow activity the account would likely exists depending on how the workflow is called.   Again, not sure without testing though.

    Best Regards,

    Tom.

  • Suggested answer
    ScottDurow Profile Picture
    21 on at
    RE: Plugin Output Parameters

    Hi,

    The OutputParameters will contain the Response object properties - so for a Create Request, it will contain the Create Response properties - which is why it contains the id property that will be returned by the platform - msdn.microsoft.com/.../microsoft.xrm.sdk.messages.createresponse.id.aspx

    For more information see msdn.microsoft.com/.../gg309673.aspx

    Hope this answers your question!

  • ScottDurow Profile Picture
    21 on at
    RE: Plugin Output Parameters

    Hi,

    Do you need any more help from Tom or I?

  • Community Member Profile Picture
    on at
    RE: Plugin Output Parameters

    Hi Scott,

    Just wanted to verify my understanding regarding this.

    Scenario : A plugin is written on Create message of a entity A. Through this plugin I would like to add a task and attach it to the created entity record. So I will need the ID of the created record.

    According to your explanation, for a create message, id is found in output parameters as it is a response object but not in input parameters.

    I tried getting entity.PrimaryEntityID in the same context. Below are the results.

    context.PrimaryEntityId : d736d2f5-c92b-e611-80ca-448a5bb3f17f

    (context.OutputParameters["id"].ToString()) --->  d736d2f5-c92b-e611-80ca-448a5bb3f17f

    My question still remains the same. Why does the official microsoft code get id from outputparameters when you can easily get from context.PrimaryEntityId in general. Is it due to any performance enhancement?

  • Community Member Profile Picture
    on at
    RE: Plugin Output Parameters

    Look into my reply above.

    Additionally, Tom and Scott

    i have got the id from both ways, interested in knowing the recommended way and why.

    I observed while debugging that, entity on which I have registered the plugin won't be created when I am running a profiler. Post create plugin error will restrict from creating the record ? Can we say this.

  • Suggested answer
    ScottDurow Profile Picture
    21 on at
    RE: Plugin Output Parameters

    Hi,

    The OutputParameters["id"] will only be populated on the Post Pipeline stage - it isn't present in the Pre stage. I think the SDK sample is using the id because it's intended to be registered at the Post stage and the OutputParameters are immutable and so will always give you what was applied in the transaction.

    There isn't any performance gain over the context.PrimaryEntityId or indeed ((Entity)InputParameters("Target")).Id - they would all return normally the same.

    Hope this answers your question?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans