【发布时间】:2017-02-21 14:47:17
【问题描述】:
我正在尝试为 Microsoft Dynamics CRM Online 中的电子邮件实体编写插件。假设它叫做“Sample_PlugIn”。
我希望插件检索电子邮件的发件人,并将他/她的电子邮件地址写入电子邮件的字段(new_samplefield)。
插件还做了一些其他的事情(而且一切正常),但这部分代码是造成问题的部分。 (我的组织服务引用称为“服务”。)
try
{
Entity email = (Entity)context.InputParameters["Target"];
EntityCollection fromCollection = (EntityCollection)email.Attributes["from"];
if (fromCollection != null && fromCollection.Entities.Count > 0)
{
Entity sender = fromCollection[0];
email["new_samplefield"] = (string)sender.Attributes["internalemailaddress"];
}
service.Update(email);
}
每次执行插件都会报这个错误:
插件意外异常(执行): Sample_PlugIn.Sample_PlugIn: System.Collections.Generic.KeyNotFoundException:给定的密钥不是 出现在字典中。
如果有人可以帮助我,那就太好了 - 非常感谢!
【问题讨论】:
标签: c# plugins dynamics-crm dynamics-crm-online dynamics-crm-2016