Can I update the contact owner ID using LINQ?

I am using CRM 2011 and trying to update the Contact OwnerId using this code:

var crmContext = new CustomCrmContext(service); var contact = crmContext.Contact.FirstOrDefault(c=>c.Id == id); contact.OwnerId.Id= newOwnerId; crmContext.UpdateObject(contact); crmContext.SaveChanges(); 

I get no errors, however ownerId is never updated in the database. I can update other attributes, but I'm just wondering if it is possible that OwnerId is special and you should use OrganizationRequest? If so, where is this documented, so I know what other attributes I cannot update?

+8
linq dynamics-crm-2011
source share
1 answer

The owner of the record cannot be changed with the update. You must send AssignRequest .

 // Create the Request Object and Set the Request Object Properties var request = new AssignRequest { Assignee = new EntityReference(SystemUser.EntityLogicalName, _newOwnerId), Target = new EntityReference(Account.EntityLogicalName, _accountId) }; // Execute the Request _service.Execute(request); 
+12
source share

All Articles