Я пытаюсь написать плагин Dynamics 365 CRM, в котором я хочу создать новый «продавец».
У меня есть следующий код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
// Microsoft Dynamics CRM namespace(s)
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
namespace Microsoft.Crm.Sdk.Samples
{
public class OrderTest : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.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"];
if (entity.LogicalName != "salesorder")
return;
try
{
Entity salesorder = new Entity("salesorder");
salesorder["name"] = "order test";
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
tracingService.Trace("OrderTestPlugin: Creating the order test.");
Guid orderId = service.Create(salesorder);
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred in the OrderTest plug-in.", ex);
}
//</snippetFollowupPlugin3>
catch (Exception ex)
{
tracingService.Trace("OrderTestPlugin: {0}", ex.ToString());
throw;
}
}
}
}
}
Моя проблема в том, чтоне удается создать продавца.Сообщение об ошибке, которое я получаю, бесполезно.Там написано: Download the details and load with Plug-in Profiler.
с последующим длинным жетоном.Я не понимаю, как создать «продавец» и как получить более понятное сообщение об ошибке.