【转】Dynamics CRM:“the given key was not present in the dictionary”
生活随笔
收集整理的這篇文章主要介紹了
【转】Dynamics CRM:“the given key was not present in the dictionary”
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
在插件中無意中撞到這個問題,其實很簡單,就是調(diào)用外部的web service,然后根據(jù)回傳結(jié)果更新記錄中的field
網(wǎng)上的建議都是要檢查這個key是否存在,開始時很不理解,這個field肯定存在的啊,怎么還需要檢查呢
之后加trace,嘗試著用attribute.contains檢查了一下,原來真的不存在
記下來以后要注意一點,對于實體記錄,如果field 值是空的話,不返回這個field
這樣只能添加,而不是直接賦值
標(biāo)準(zhǔn)代碼如下
if (e.Attributes.Contains("new_expressstatus"))
{
??? e["new_expressstatus"] = result;
}
else
{
??? e.Attributes.Add("new_expressstatus", result);
}
總結(jié)
以上是生活随笔為你收集整理的【转】Dynamics CRM:“the given key was not present in the dictionary”的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 企业可以随意开商业承兑汇票吗
- 下一篇: 【转】关于字符编码,你所需要知道的