Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Plugin Syntax

Posted on by Microsoft Employee

HI all,

Can any one explain me about this Syntax.

IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

Best Regards,

Praveen Kumar.C

*This post is locked for comments

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Plugin Syntax

    Hi Praveen Kumar,

    IPluginExecutionContext is where all the contextual information is brought to your code. InputParameters and OutputParameters member contain, for example, the record the plugin is being fired upon, the pre- and post-image, the handled message. These are all part of syntax for a plugin.

    public void Execute(IServiceProvider serviceProvider)
    {
    
         IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    
         IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory) serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    
         IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
    }
    

     For getting the details of the IPluginExecutionContext, please refer the link below.

    https://msdn.microsoft.com/en-in/library/microsoft.xrm.sdk.ipluginexecutioncontext.aspx

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Plugin Syntax

    Hello,

    In mentioned line code gets instance of IPluginExecutionContext frin serviceProvider. I'm not sure what confuses you?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans