Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

i am getting error when I create a contact based on account.

(0) ShareShare
ReportReport
Posted on by 20

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);

            }
        }
    }
}
WhatsApp-Image-2020_2D00_01_2D00_16-at-9.49.25-AM.jpeg

please help me to resolve the error 

  • Anas Rafik Profile Picture
    Anas Rafik 363 on at
    RE: i am getting error when I create a contact based on account.

    You need to delete your credentials and change your password

  • tctsl1013 Profile Picture
    tctsl1013 20 on at
    RE: i am getting error when I create a contact based on account.

    sure sir.........belated happy sankranti..............

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: i am getting error when I create a contact based on account.

    Inside your log you have following - " 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.'"

    So it said me that "Sync workflow 'shan'" caused the error. That's pretty it - no magic.

    If it resolved your issue don't forget to close the thread and verify my replies as verified answers.

  • tctsl1013 Profile Picture
    tctsl1013 20 on at
    RE: i am getting error when I create a contact based on account.

    sir.....superb awesome, no words to your analysis.  my plugin  is executed i have get output .

    how to analyse the error log code ..?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: i am getting error when I create a contact based on account.

    Don't get me wrong - I will not touch your instance and it's safer for you to delete credentials.

    The workflow that causes error is called "shan" according to your log. Deactivate or fix it.

  • tctsl1013 Profile Picture
    tctsl1013 20 on at
    RE: i am getting error when I create a contact based on account.

    deactivated the word count workflows same as try to unregistered the same word count workflow

    plugin in plugin registration tool but i was not unregistered.

  • tctsl1013 Profile Picture
    tctsl1013 20 on at
    RE: i am getting error when I create a contact based on account.

    no sir "muralikrishna"

  • tctsl1013 Profile Picture
    tctsl1013 20 on at
    RE: i am getting error when I create a contact based on account.

    URL:tctsl1013.crm8.dynamics.com/main.aspx

    user name:muralikrishna@TCTSL1013.onmicrosoft.com

    password:Dynamics365

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: i am getting error when I create a contact based on account.

    What workflow did you deactivate? Is it the one called "shan"?

  • tctsl1013 Profile Picture
    tctsl1013 20 on at
    RE: i am getting error when I create a contact based on account.

    thanks for reply sir....can i send my instance ..?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans