1
下面的代码在的WriteLine抛出一个KeyNotFoundException():动态CRM 2015年在线:将无法获取自定义字段
CrmConnection crmConnection = CrmConnection.Parse(_connectionString);
using (OrganizationService service = new OrganizationService(crmConnection))
{
QueryExpression query = new QueryExpression
{
EntityName = "contact",
ColumnSet = new ColumnSet("fullname", "new_customer_num", "new_is_customer"),
};
EntityCollection contacts = service.RetrieveMultiple(query);
if (contacts.Entities.Count > 0)
{
foreach (var e in contacts.Entities)
{
System.Diagnostics.Debug.WriteLine(
e.Attributes["fullname"].ToString() + "; " +
e.Attributes["new_is_customer"].ToString());
}
}
}
我已经添加new_customer_num和new_is_customer(需要)字段联系人实体。如果我故意拼错它们,则FaultException抛出service.RetrieveMultiple(query);所以我猜CRM“知道”我的自定义字段。那为什么不查询结果包含它们呢?
你能告诉我你为什么用new_替换ht_吗?我尝试这个,但它不适合我 – 2017-06-15 10:23:43