I am doing a tool to synchronize some to data between CRM and another application. Now I have to remove the value from a EntityReference. I am trying in this way:
contact.ParentCustomerId = null;
But it does not work. That does not give me any error bur when I go to CRM via browser the field is till valorized. I have also tried in this way:
contact.ParentCustomerId = new EntityReference(Crm.Context.Account.EntityLogicalName, Guid.Empty);
but this give me a runtime error.
How can I solve? Thank you
UPDATE :
Crm.Context.Contact contatto = ContattiTOA.Transform(c, account); //Inside the transform you can see that line of code I posted before..
var entityToUpdate = this._context
.ContactSet
.Where(cont => cont.new_SIP_id == contatto.new_SIP_id || cont.Id == contatto.Id)
.First();
if (entityToUpdate.new_SynchronizewithSIP.HasValue && entityToUpdate.new_SynchronizewithSIP.Value == true)
{
contatto.Id = entityToUpdate.Id;
contatto.OwnerId = entityToUpdate.OwnerId;
contatto.EntityState = EntityState.Changed;
request = new UpdateRequest { Target = contatto };
}
requests.Requests.Add(request);
ExecuteMultipleResponse responses = (ExecuteMultipleResponse)this._context.Execute(requests);
foreach (var responseItem in responses.Responses)
{
if (responseItem.Fault != null)
{
... // I never fall in here
}
}