I was getting the “Attribute ‘xxxx’ cannot be NULL” error while attempting to update a CRM entity. What I was trying to do was to use the Entity object to perform an update and I think that was causing an error as the attribute ‘xxxx’ which was a required attribute did not have a value. But in my case, all I was trying to do was to update one of the attributes of that entity.
The original code that did not work:
Incident incident = new Incident(); incident.IncidentId = incidentGuid; contact.new_Contact_Incident_Id = incident;
I was able to get my code working by using the EntityReference object. Here is the working code:
EntityReference incidentRef = new EntityReference(Incident.EntityLogicalName, incidentGuid); contactEntity[“new_contact_incident_id”] = incidentRef; PluginContext.OrganizationService.Update(contactEntity);
No comments:
Post a Comment
Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.