简体   繁体   English

如何将国家/地区数据插入MS Dynamics CRM Lead实体

[英]How to insert Country data to the MS Dynamics CRM Lead entity

How to insert country data ( Address1_Country ) to the MS Dynamics CRM Lead entity? 如何将国家/地区数据( Address1_Country )插入MS Dynamics CRM Lead实体?

I am using the Xrm.cs and Microsoft.Xrm.Sdk NuGet package. 我正在使用Xrm.cs和Microsoft.Xrm.Sdk NuGet包。 I would like to add a country data along the new Lead entity that I am creating. 我想在我创建的新的Lead实体中添加国家/地区数据。

I have no problem creating a new Lead entity, like: 我可以轻松创建一个新的Lead实体,例如:

在此处输入图片说明

And I am adding a country data along other data to the Lead entity, like: 我正在将国家/地区数据以及其他数据添加到潜在客户实体,例如:

在此处输入图片说明

But the country data does not get passed further to the CRM: 但是国家/地区数据并未进一步传递给CRM:

在此处输入图片说明

I have NO idea what is wrong. 我不知道怎么了。 The Address1_Country data is string type. Address1_Country数据是string类型。 So I have tried also data like "DE" and it does not work. 所以我也尝试过像“ DE”这样的数据,它不起作用。

However it is true that country data here is a special data - lookup one. 但是,这里的国家/地区数据确实是一种特殊数据-查找。 I am sure that this and my problem is somehow connected. 我确定这和我的问题之间存在某种联系。 Maybe I should fill the Id or Guid in? 也许我应该填写ID或Guid? But Usually in Xrm.cs those data are also Guid data type .. So I am a bit lost here. 但是通常在Xrm.cs中这些数据也是Guid数据类型..因此,我在这里有点迷失了。

How can I fill the country data in CRM via C# API? 如何通过C#API在CRM中填写国家/地区数据?

If Country is a lookup type, you need to set there an EntityReference . 如果Country是查找类型,则需要在那里设置EntityReference

Address1_Country = new EntityReference("entityLogicalName", Guid);

So you need to Retrieve the Guid of the country you want to set there (If you are going to filter by name you need a RetrieveMultiple) and set that Id there. 因此,您需要检索要在此处设置的国家/地区的Guid(如果要按名称进行过滤,则需要RetrieveMultiple)并在那里设置ID。

This is the approach with Late Bound, I think you are using Early Bound, you only need to parse this to Early. 这是Late Bound的方法,我想您正在使用Early Bound,您只需要将此解析为Early。

I think you need to double check the field on the form is the same field you are referencing. 我认为您需要仔细检查表单中的字段是否与您所引用的字段相同。 Open the properties of the field on the form, and open the Details tab and check the field name. 打开表单上字段的属性,然后打开“详细信息”选项卡并检查字段名称。

My guess is that it is likely a different address field. 我的猜测是,它可能是一个不同的地址字段。

Another way to verify this would be to look at all the columns for the record in an Advanced Find view. 验证此问题的另一种方法是在“高级查找”视图中查看记录的所有列。

Hopefully that helps. 希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM