dear sir,please error log. Unhandled exception: Exception type: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault] Message: An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): WordCountWorkflow.WordCount: System.NullReferenceException: Object reference not set to an instance of an object.Detail: 6dff47fa-52ef-4fd3-93c0-47cc509ec6de -2147220891 ApiExceptionSourceKey Plugin/$Microsoft.Crm.Workflow.Services.ProxyCustomActivity ApiOriginalExceptionKey Microsoft.Crm.CrmException: An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): WordCountWorkflow.WordCount: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Crm.Sandbox.SandboxCodeUnit.ProcessException(Exception originalException, IExecutionContext context, SandboxClient client, SandboxCallTracker callTracker, Boolean isSafeToRetry, DateTime performanceExecutionStartTime, SandboxTracker tracker, Guid parentExecutionId, CrmException& crmException, String& assemblyContents) at Microsoft.Crm.Sandbox.SandboxCodeUnit.<>c__DisplayClass24_0.b__0() at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties) at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePlugin.CDSExecute(IServiceProvider serviceProvider) at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext) ApiStepKey 3be440b7-c633-ea11-a813-000d3af270de ApiDepthKey 2 ApiActivityIdKey 4e2da93c-def1-4ec7-bfad-dae5903b1fb6 ApiPluginSolutionNameKey System ApiStepSolutionNameKey System ApiExceptionCategory ClientError ApiExceptionMesageName IsvUnExpected ApiExceptionHttpStatusCode 400 OperationStatus 0 SubErrorCode -2146233088 http://go.microsoft.com/fwlink/?LinkID=398563&error=Microsoft.Crm.CrmException:80040265&client=platform An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): WordCountWorkflow.WordCount: System.NullReferenceException: Object reference not set to an instance of an object. 2020-01-16T14:26:34.201675Z false [ClassLibrary2: ClassLibrary2.Class1] [7012e08a-c137-ea11-a813-000d3af270de: ClassLibrary2.Class1: Create of account] [Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin] [3be440b7-c633-ea11-a813-000d3af270de: ] Starting sync workflow 'shan', Id: 34e440b7-c633-ea11-a813-000d3af270de Entering CustomActivityStep1_step: Sync workflow 'shan' terminated with error 'An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): WordCountWorkflow.WordCount: System.NullReferenceException: Object reference not set to an instance of an object.'
ing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xrm.Sdk; namespace ClassLibrary2 { public class Class1 : IPlugin { public object Account { get; private set; } 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)); // Obtain the organization service reference. IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity account = (Entity)context.InputParameters["Target"]; Entity contact = new Entity("contact"); contact.Attributes["firstname"] = account.Attributes["name"]; Guid contactid = service.Create(contact); account.Attributes["primarycontactid"] = new EntityReference("contact", contactid); } } } }
please help me to resolve the error