Hello All,
We are experiencing a strange error in the below mentioned code
var record = new Contact
{
FirstName = DataGenerator.RandomName(),
LastName = DataGenerator.RandomName(),
BirthDate = birthdate.AddDays(1),
Custom_Attribute1= XXXXX
}
var createRequest = new CreateRequest
{
Target = record,
};
record.Id = ((CreateResponse)context.OrganizationService.Execute(createRequest)).id;
The error occurrs intermittently and it is
An unexpected error occurred. NullReferenceException
at the above highlighted line, some time the record is created without any error.
Is this because some of the attributes missing when creating the record?
We are using Dynamics 365 on premise Version 1612 (8.2.28.11) (DB 8.2.28.11) on-premises.
There are some plugins on OnCreate Pre and Post Operation of the Contact, and the aove mentioned code is in the Web API which is used by some application.
If anyone has some inputs with such similar issue, please let me know.
Regards,
Abhi.