Skip to main content

Notifications

Microsoft Dynamics CRM forum
Suggested answer

What is difference between IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM

Posted on by 20

Please explain difference and use of senario of  IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM.

As I know IPluginExecutionContext we used in plugin that run of CRM. but I don't know others use

Categories:
  • Suggested answer
    Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,393 Moderator on at
    RE: What is difference between IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM

    Hi Shaun,

    You can take a look at this documentation:

    learn.microsoft.com/.../microsoft.xrm.sdk.ipluginexecutioncontext

  • Shaun W Harvey Profile Picture
    Shaun W Harvey 240 on at
    RE: What is difference between IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM

    Is there a link in the documentation somewhere as to these changes and when they occurred?

    Just curious, as properties such as plugin depth, shared variables and pre/post entity images have been in the original IPluginExecutionContext interface since at least the CRM2011/2013 days from what I can remember.

  • Suggested answer
    Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,393 Moderator on at
    RE: What is difference between IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM

    Hi Radhika,

    the IPluginExecutionContext interface is used to provide information about the current plugin execution context to the plugin code. It provides access to a number of objects and properties that can be used by the plugin to perform its logic. There are multiple versions of this interface, each with slightly different functionality:

    • IPluginExecutionContext: This is the original version of the interface, which provides basic information about the current plugin execution context, such as the input parameters, output parameters, and the target entity.

    • IPluginExecutionContext2: This version of the interface was introduced in Dynamics 365 (CRM) and provides additional functionality over the original version, including the ability to access the related entities, the depth of the plugin execution, and the business process flow stage, if applicable

    • IPluginExecutionContext3: This version of the interface was introduced in Dynamics 365 (CRM) and provides additional functionality over the previous version such as access to the shared variables, the source entity of an operation, the Target Entity and Pre Entity images

    • IPluginExecutionContext4: This version of the interface was introduced in Dynamics 365 (CRM) and provides additional functionality over the previous versions such as access to the execution context mode, the initiating user and its related attributes, access to the child pipeline execution context, and the ability to cancel the execution of the plugin

    As you can see, each version of the IPluginExecutionContext interface provides additional functionality over the previous version. When developing plugins for Dynamics 365 CRM, you can use the version of the interface that best suits the needs of your plugin. As newer version of the interface have been introduced, developers can have

  • Shaun W Harvey Profile Picture
    Shaun W Harvey 240 on at
    RE: What is difference between IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM

    I think "3" has an additional "AuthenticatedUserId" property.

    "4" Implements all the previous ones, so you would get access to everything.

    Where and when you would use them I can't say.

  • Shaun W Harvey Profile Picture
    Shaun W Harvey 240 on at
    RE: What is difference between IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM

    From the documentation it suggests IPluginExecutionContext2 has extra details when changes have come from a Dynamics Portal.

    It is not obvious what 3 and 4 are for though.

    IPluginExecutionContext Interface (Microsoft.Xrm.Sdk) | Microsoft Learn

    IPluginExecutionContext2 Interface (Microsoft.Xrm.Sdk) | Microsoft Learn

    IPluginExecutionContext3 Interface (Microsoft.Xrm.Sdk) | Microsoft Learn

    IPluginExecutionContext4 Interface (Microsoft.Xrm.Sdk) | Microsoft Learn

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Moderator on at
    RE: What is difference between IPluginExecutionContext ,IPluginExecutionContext2,IPluginExecutionContext3,IPluginExecutionContext4 D365 CRM

    Hi Radhika,

    I think they might be running in a different context. Can you please share some more code details?

    May it is because of the impersonation. For more details: 

    1. https://learn.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/impersonation-plugins?view=op-9-1
    2. learn.microsoft.com/.../impersonate-a-user

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans