dynamics-crm - 如何传递 EntityReference 以在 Microsoft Dynamics 365 CRM 中的查找字段上添加属性值
问题描述
Entity contact = new Entity("contact");
contact.Attributes.Add("fullname", "h api test");
contact.Attributes.Add("emailaddress1", "hh@devenv1.local");
contact.Attributes.Add("telephone1", "1");
contact.Attributes["parentcusotmerid"] = new EntityReference("Organization", );
Guid contactId = m_OrgServ.Create(contact);
Console.WriteLine(contactId);
查找字段的逻辑名称是parentcusotmerid
, 和
m_OrgSerc.create
基本上是
Service.create
我正在为字段设置属性值,它适用于我输入值的普通文本框,但是对于查找值它不起作用。我知道查找字段的类型为EntityReference
,因此我需要知道LogicalName
查找指向的实体的类型和Id
记录的类型。
我已经尝试过了,但它现在要求提供组织字段的 GUID,所以我不确定我是否以正确的方式进行操作?
解决方案
您不能将“parentcustomerid”设置为组织。它是一个特殊的引用字段,它以 Account 或 Contact 实体引用作为参数。
如果你想设置它,你可以这样
contact.Attributes["parentcusotmerid"] = new EntityReference("account", Guid.NewGuid());
或者
contact.Attributes["parentcusotmerid"] = new EntityReference("contact", Guid.NewGuid());
其中 Guid.NewGuid() 是您要引用的帐户或联系人的 Guid
推荐阅读
- c# - IIS 如何控制 WCF 生命周期服务并将 InstanceContextmode 设置为单一?
- asp.net-mvc - 除了使用 efcore 的存储库模式中的 CRUD 操作方法之外,我还需要在哪里编写自定义方法?
- sass - 如何将 vuetify scss 变量导入组件
- javascript - 滑动关闭汉堡菜单
- c++ - 在向量中添加两个相邻元素,给出奇数的分段错误(c++)
- python - 测量到最近的一组点的距离 - python
- twilio - 如何使用 Twilio 热转电话会议?
- javascript - 属性图显示未定义
- sass - 使用 @use 导入文件时:Error Undefined Mixin
- laravel - 使用 barryvdh/laravel-dompdf 在每一页上重复标题