Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 123975

Forum Post: RE: Create object OrganizationServiceProxy CRM Plugin

$
0
0

Hi,

From within a plugin you should use the in-process service, all samples in the sdk use this approach, it does not require hardcoding credentials.

       public void Execute(IServiceProvider serviceProvider)

       {

           // Obtain the execution context from the service provider.

           IPluginExecutionContext context =

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

           // Get a reference to the organization service.

           IOrganizationServiceFactory factory =

               (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

           IOrganizationService service = factory.CreateOrganizationService(context.UserId);

msdn.microsoft.com/.../gg328263.aspx

Thanks,

Matt


Viewing all articles
Browse latest Browse all 123975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>