ユーザーがレコード自体を更新した直後に、販売注文の一部のデータを更新するプラグインを作成しました。特定の日付が変更されたかどうかに基づいて、書式設定された日付で別のフィールドを更新したいと考えています。
「指定されたキーが辞書に存在しませんでした」というエラーに出くわしたので、いくつかのトレースを追加して、エラーが正確に返された場所を確認しました。その後、トレースが書き出されないことがわかったので、書いたコードが実行されることはないと思いました。これは確かにそうです。
public class SalesOrderPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
}
}
同じエラーが表示されます:
Unhandled Exception: System.ServiceModel.FaultException`1
[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]:
Unexpected exception from plug-in (Execute): Iu.PreConsultants.Crm.SalesOrderPlugin:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220956</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Unexpected exception from plug-in (Execute): Iu.PreConsultants.Crm.SalesOrderPlugin: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.</Message>
<Timestamp>2012-02-21T07:09:48.471378Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>
[Iu.PreConsultants.Crm: Iu.PreConsultants.Crm.SalesOrderPlugin]
[1486b5df-595c-e111-b7b0-46c950e6c8cd: Iu.PreConsultants.Crm.SalesOrderPlugin: Update of salesorder]
</TraceText>
</OrganizationServiceFault>
プラグインの設定:
- 事後検証
- 同期実行モード
- サーバーの展開
ホストされたセットアップ (サンドボックス)
SalesOrder は変更されており、いくつかのカスタム属性があります。
これに関する助けがあれば大歓迎です!
敬具、
ヴィンセント