在没有早期绑定实体的CRM中创建ActivityParty

Kir*_*chi 7 c# dynamics-crm

作为要求,我不能使用用"CrmSvcUtil"创建的早期绑定上下文.的问题是,一个新活动phonecall预计两个字段("发件人"和"到"),它们是Entities类型activityparty.标准XRM/CRM命名空间不包含ActivityParty与使用Utility创建的类似的类.

我尝试用EntityCollection填充它,但该字段将为空.接下来,我尝试重新创建一个有效的电话呼叫活动的结构.EntityCollection" activityparty " - >一个Entity" activityparty " - > EntityReference属性" partyid " - >实体引用(例如"联系人"和联系人的ID).但它根本行不通.

如何使用"普通" Entitiy类创建ActivityParty(或更好的电话呼叫活动)?

Gui*_*ite 18

如果我是对的,你不需要使用EntityCollection一个数组Entity

使用后期绑定语法创建电话将是:

Entity from1 = new Entity("activityparty");
Entity to1 = new Entity("activityparty");
Entity to2 = new Entity("activityparty"); // two contacts inside the to field

from1["partyid"]= new EntityReference("systemuser", userId);
to1["partyid"]= new EntityReference("contact", contact1Id);
to2["partyid"]= new EntityReference("contact", contact2Id);

Entity phonecall = new Entity("phonecall");

phonecall["from"] = new Entity[] { from1 };
phonecall["to"] = new Entity[] { to1, to2 };
// other phonecall fields

Guid phonecallId = service.Create(phonecall);
Run Code Online (Sandbox Code Playgroud)