我是CRM開發新手。除了我的C#應用程序中的CRM 2011中的現有值外,我還想更新自定義字段值。如果該字段有一些值,那麼它工作正常,但如果它爲空,那麼我正在接收「給定的密鑰不在字典中。」錯誤。使用QueryByAttribute無法檢索空值
下面的代碼是我想要實現的。
IOrganizationService service = (IOrganizationService)serviceProxy;
QueryByAttribute querybyattribute = new QueryByAttribute("salesorder");
querybyattribute.ColumnSet = new ColumnSet(new String[] {
"salesorderid", "new_customefield" });
querybyattribute.Attributes.AddRange("ordernumber");
querybyattribute.Values.AddRange(ordernumber);
EntityCollection retrieved = service.RetrieveMultiple(querybyattribute);
foreach (var c in retrieved.Entities)
{
OrderID = new Guid(c.Attributes["salesorderid"].ToString());
CustomFieldValue = c.Attributes["new_customefield"].ToString();
}
Mr.Konrad,非常感謝您的快速反應。我已經使用CustomFieldValue = c.GetAttributeValue(「new_customfield」) ,它的作用就像一個魅力。 –
crmdev
2013-02-27 07:26:20