This problem is due to checking for depth in plugin, the async job that inserts imported data into CRM
sets plugin depth to '2', so the solution is to disable check for depth while data import.
This problem is due to checking for depth in plugin, the async job that inserts imported data into CRM
sets plugin depth to '2', so the solution is to disable check for depth while data import.
The OwningExtension property available on the IpluginExecutionContext returns an EntityRefrence to the SdkMessageProcessing Step which have all the information of the step.
Hi ,
I am going to show in the following steps how to trigger plugin on Action execution in CRM
Steps
1) Create Action
2) Register plugin
3) Call Action
The following code will show how to call the action using C#
OrganizationRequest callActionRequest = new OrganizationRequest("qdrn_setcustomervip");
callActionRequest["Target"] = new EntityReference("contact", {GUID});
OrganizationResponse callActionResponse = service.Execute(callActionRequest);
Hi,
The following code illustrates how to get user settings inside plugin execution code
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the execution context from the service provider.
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
//Get Reference to an instance of the Organization Service
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
// Set the Request
RetrieveUserSettingsSystemUserRequest userSettingsSystemUserRequest = new RetrieveUserSettingsSystemUserRequest
{
ColumnSet = new ColumnSet() { AllColumns = true },
EntityId = context.UserId
};
//Get the response
RetrieveUserSettingsSystemUserResponse UserSettings = (RetrieveUserSettingsSystemUserResponse)service.Execute(userSettingsSystemUserRequest);
// Get the time zone of the user
TimeZoneCode = UserSettings.Entity["timezonecode"].ToString();
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
}