Skip to content

Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.Create fails when custom EntityReference property is set to null #179

@mjfpalmer

Description

@mjfpalmer

If I set the value of a custom EntityReference field on an early bound instance of the incident entity, then attempt to create the incident using Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.Create, I receive the error below:

System.AggregateException: 'incident.new_testid : GetAttributeMetadata : RequestID=5b6844c4-2f)'

Inner Exception
NullReferenceException: Object reference not set to an instance of an object.

If I call the same create with a value for new_testid or I don't set new_testid at all (ie. don't push it into the property bag), then the create succeeds. This behaviour is different to the behaviour of CrmServiceClient.Create which would allow the Create to work with null EntityReference.

Code snippet below for reference

Microsoft.PowerPlatform.Dataverse.Client.ServiceClient serviceClient = new ServiceClient("[connection string]");

Incident incident = new Incident
{
  Title = "Test Case",
  CustomerId = new EntityReference(Account.EntityLogicalName, new Guid("CAA50976-5541-4C40-BCA5-21F296CF4A71")),
  new_TestId = null,
};

serviceClient.Create(incident);

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions