提问人:HH44 提问时间:5/23/2020 最后编辑:marc_sHH44 更新时间:5/24/2020 访问量:4082
如何传递实体引用以在 Microsoft Dynamics 365 CRM 中的查找字段上添加属性值
How to pass an EntityReference to add attribute value on a lookup field in Microsoft Dynamics 365 CRM
问:
Entity contact = new Entity("contact");
contact.Attributes.Add("fullname", "h api test");
contact.Attributes.Add("emailaddress1", "[email protected]");
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,所以我不确定我是否以正确的方式进行?
答:
2赞
minohimself
5/24/2020
#1
不能将“parentcustomerid”设置为 organization。它是特殊的引用字段,采用“客户”或“联系人”实体引用作为参数。
如果你想设置它,你可以这样
contact.Attributes["parentcusotmerid"] = new EntityReference("account", Guid.NewGuid());
或
contact.Attributes["parentcusotmerid"] = new EntityReference("contact", Guid.NewGuid());
其中 Guid.NewGuid() 是要引用的客户或联系人的 Guid
评论
0赞
HH44
5/24/2020
但正如你从我上传的图像中看到的那样。我想将“parentcustomerid”的“组织名称”字段设置为值“BAE Systems plc”......因此,在您给出的这段代码中,我可以指定..所以这就是被关注和选择的价值?
0赞
Arun Vinoth-Precog Tech - MVP
5/24/2020
@HH44将父客户查找重命名为“组织”,则如果已创建“BAE 系统”帐户记录,则必须获取该记录的 GUID。具有实体引用的 guid 是设置它的唯一方法。我们不能只用名字来设置。
0赞
minohimself
5/24/2020
正如 Arun 所说,如果 BAE 系统记录的 GUID 已存在,请将 referenz 设置为帐户
评论