Hello,
I have created a plugin which calls whenever entity modified date gets an update. I want to get Organization Service URI in it. i.e https://organizationname.crm.dynamics.com/XRMServices/2011/Organization.svc
public void Execute(IServiceProvider serviceProvider)
{
//Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext) serviceProvider.GetService(typeof(IPluginExecutionContext));
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
try
{
//// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
//how to get organizationname.crm.dynamics.com/.../Organization.svc
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(String.Format("Handling custom plug-in: {0}", ex.Message), ex);
}
}
}
Can I get it using IPluginExecutionContext or IOrganizationServiceFactory or IOrganizationService?
Please suggest.
*This post is locked for comments
I have the same question (0)