We are able to create new entities without any issues, but updating an existing entity in a plugin this does not appear to be working. This is for CRM 2011.
var crmContext = new CustomCrmContext(service);
var contact = crmContext.Contact.FirstOrDefault(c=>c.Id == targetEntity.Id);
contact.new_CustomField = "Updated";
crmContext.SaveChanges();
No need to download the whole Contact record if you already have the Id and you just need to update a field or two. You also don't need the OrganizationServiceContext - just the Service. Try something like:
var c = new contact() {
Id = targetEntity.Id,
new_CustomField = "Updated"
}
service.Update(c);
This will save the roundtrip of querying for the contact first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With