Dar*_*ryl 8 linq dynamics-crm-2011
我正在使用CRM 2011,并尝试使用以下代码更新联系人的OwnerId:
var crmContext = new CustomCrmContext(service);
var contact = crmContext.Contact.FirstOrDefault(c=>c.Id == id);
contact.OwnerId.Id= newOwnerId;
crmContext.UpdateObject(contact);
crmContext.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
我没有收到任何错误,但是,ownerId永远不会在数据库中更新.我能够更新其他属性,但我只是想知道如果OwnerId是特殊的,你必须使用OrganizationRequest("分配")?如果是这样,这在哪里记录,所以我知道我无法更新的其他属性?
cce*_*lar 12
无法使用更新修改记录的所有者.您必须改为发送AssignRequest.
// Create the Request Object and Set the Request Object's Properties
var request = new AssignRequest
{
Assignee = new EntityReference(SystemUser.EntityLogicalName, _newOwnerId),
Target = new EntityReference(Account.EntityLogicalName, _accountId)
};
// Execute the Request
_service.Execute(request);
Run Code Online (Sandbox Code Playgroud)