[英]Dynamic CRM : Need to update Connection entities via API
我已經通過以下代碼通過API創建了連接( Dynamics Crm:通過API創建了連接實體
Entity connection = new Entity("connection");
connection["record1id"] = new EntityReference("contact", someContactId);
connection["record1objecttypecode"] = new OptionSetValue(2);
connection["record1roleid"] = new EntityReference("connectionrole", someConnectionRoleId);
connection["record2id"] = new EntityReference("incident", someCaseId);
connection["record2objecttypecode"] = new OptionSetValue(122);
connection["record2roleid"] = new EntityReference("connectionrole", someOtherConnectionRoleId);
var newId = service.Create(connection);
問題:我需要更新兩個記錄之間的連接角色。
如果我正確理解了該問題,則只需要沿着相同的道路前進,使用從“ Create
獲得的ID來引用記錄:
// Your code
Entity connection = new Entity("connection");
connection["record1id"] = new EntityReference("contact", someContactId);
connection["record1objecttypecode"] = new OptionSetValue(2);
connection["record1roleid"] = new EntityReference("connectionrole", someConnectionRoleId);
connection["record2id"] = new EntityReference("incident", someCaseId);
connection["record2objecttypecode"] = new OptionSetValue(122);
connection["record2roleid"] = new EntityReference("connectionrole", someOtherConnectionRoleId);
var newId = service.Create(connection);
// And then ...
connection = new Entity("connection"); // start from scratch
connection["connectionid"] = newId; // needed for the CRM to know what to update
connection["record1roleid"] = new EntityReference("connectionrole", yetAnotherConnectionRoleId);
connection["record2roleid"] = new EntityReference("connectionrole", yetAnotherAnotherConnectionRoleId);
service.Update(connection);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.