CRM開発初心者です。C# アプリケーションから CRM 2011 の既存の値に加えて、カスタム フィールドの値を更新したいと考えています。フィールドにいくつかの値がある場合は正常に機能していますが、null の場合は「指定されたキーが辞書に存在しませんでした」というメッセージが表示されます。エラー。
以下のコードは、私が達成しようとしているものです。
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();
}