Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin execution information in context.

(0) ShareShare
ReportReport
Posted on by 290

I have a plugin which is running on entity "X" and it updates records in another entity "Y" from N:N relationship. From the  entity "Y" another plugin is triggering on the same update.

Is there any way to get the triggering record ID of "X" from the plugin triggering from "Y" ?.

Thanks in advance.

*This post is locked for comments

  • Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Plugin execution information in context.

    create a field in Y entity to store X entity ID, update that field only if it trigger from X entity else it will be blank and in your Y entity Plugin you can check the condition If that field value exists,

    means it is from X entity and with the help of QueryExpression or Fetch XML your can retrieve value from X entity as you have X entity ID in custom field of Y entity...

  • Jomy Jose Profile Picture
    290 on at
    RE: Plugin execution information in context.

    Hi Shahbaaz, thanks for the response.

    I had a scenario like, in Y entity both direct update and update from 'X' entity are happening(for multiple fields). if it is from X entity i need some values from X entity to do some calc.

  • Jomy Jose Profile Picture
    290 on at
    RE: Plugin execution information in context.

    Rawish, i have tried but it is not working because , 2 different plugin is running from 2 different entities. I had a scenario like below,

    let’s say that we have a plugin that executes when an Account is updated and that this plugin updates associated Contacts. Let’s also say that we have another plugin that gets triggered when the Contact is updated, so we have a case where the Account update plugin triggers this Contact update plugin.(Account and Contact have N:N relation)

    So i need the account ID from the plugin triggering in the contact.

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Plugin execution information in context.
    You can use - parentcontext.sharedvariable insteqd of context.sharedvariable.
  • Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Plugin execution information in context.

    Hi Jomy,

    You can create a field "X ID" on Y entity and when you update Y entity, update that X ID field with X entity ID.  

    And also SharedVariables is used to pass data from a pre-event registered plug-in to a post-event registered plug-in.

    Thanks,

    Shahbaaz

  • Jomy Jose Profile Picture
    290 on at
    RE: Plugin execution information in context.

    Rawish Kumar ,   Thank you so much for the instant response . I will try and will update you.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Plugin execution information in context.

    Hello Jomy,

    This functionality will be execute as infinite loop  in that case you need to check depth and parentexecutioncontext to handle it. For more details you can refer -

    crmbusiness.wordpress.com/.../stopping-infinite-plugins-with-parameters-depth-and-parentcontext

    msdn.microsoft.com/.../microsoft.xrm.sdk.iexecutioncontext.depth.aspx

    If you are associating or dissociating records then you need to use secondary entity in plugin registration tool,

    arpitmscrmhunt.blogspot.in/.../significance-of-secondary-entity-in.html

    Hope this helps

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Plugin execution information in context.

    Generally we use shared variable for these kind of information :

    msdn.microsoft.com/.../gg328579.aspx

    however in your case since plugin Y is triggering once X is done - not sure if this is possible.Give it a try.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans