Da minha experiencia com o CRM 4.0 verifiquei com mais frequência do que espectável que diversos administradores de CRM eliminaram(propositadamente ou por engano) os seguintes Plugin Steps.
Tal facto traduz-se na ocorrência de diversos erros aquando da criação/update da entidade account.
ERROR:
MessageProcessor fail to process message 'Create' for 'account' at MessageProcessor.Execute(PipelineExecutionContext context) at InternalMessageDispatcher.Execute(PipelineExecutionContext context) at ExtensiblePlatformMessageDispatcher.Execute(PipelineExecutionContext pluginContext) at ExtensiblePlatformMessageDispatcher.Create(BusinessEntity entity, ExecutionContext context) at BusinessProcessObject.CreateWithPipeline(IBusinessEntity entity, ExecutionContext context) Web Service Plug-in failed in SdkMessageProcessingStepId: {F6D4EBBB-0075-407D-8208-26575BFA39AF}; EntityName: account; Stage: 20; MessageName: Create; AssemblyName: Microsoft.Crm.ObjectModel.MultiCurrencyPlugin, Microsoft.Crm.ObjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.ObjectModel.MultiCurrencyPlugin; Exception: Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. Error: Exception has been thrown by the target of an invocation. Error Number: 0x80040265 Error Message: The given key was not present in the dictionary. Error Details: The given key was not present in the dictionary. Source File: Not available Line Number: Not available Request URL: http://.../..../sfa/accts/edit.aspx
A forma de corrigir este “descuido” (chamemos-lhe assim), é editar o código da ferramenta Plugin Registration tool. Para efectuar o download deste aplicativo use o seguinte url:
http://code.msdn.microsoft.com/crmplugin/Release/ProjectReleases.aspx?ReleaseId=2010
Para tal teremos que encontrar a linha 62 do ficheiro StepRegistrationForm.cs e comentar o bloco If() Else()
Através da edição deste pequeno troço de código poderemos então correr novamente a aplicação e manualmente adicionar os anteriormente removidos STEPS.
Os steps são os seguintes:
PARENT
CHILD
Apos recriar os steps teremos que registá-los et Voilá, ready to roll.
Note-se que com a eliminação do bloco if else, o seguinte erro não irá ocorrer, pois o campo Plugin, irá listar o Internal Operation.
Em seguida deixo uma descrição passo a passo da recriação destes steps.
A recriação Passo a Passo:
1. Localize a linha 62 do ficheiro StepRegistrationForm.cs (StepRegistrationForm). Você verá o seguinte código(sem os comentarios claro!):
/*/Check whether system plugins should be added to the list if (step != null && org[step.AssemblyId][step.PluginId].IsSystemCrmEntity) { cmbPlugins.Enabled = false; } else if (plugin != null && plugin.IsSystemCrmEntity) { plugin = null; }*/ //Add the plugins CrmPlugin selectPlugin = null; foreach (CrmPluginAssembly assembly in org.Assemblies.Values) { foreach (CrmPlugin pluginType in assembly.Plugins.Values) { if (pluginType.PluginType == CrmPluginType.Plugin)/* && pluginType.CustomizationLevel != 0)*/ { if (plugin != null )/*&& plugin.PluginId == pluginType.PluginId)*/ { selectPlugin = pluginType; cmbPlugins.Items.Add(pluginType); } else if (!pluginType.IsSystemCrmEntity) { cmbPlugins.Items.Add(pluginType); } } } }
2. Faça as alterações sugeridas(código comentado)
9.1 em plugin seleccione o Internal Operation.10. Escreva “ObjectModel Implementation” para a descrição. 11. Digite 0 para a execução da ordem. 12. Marque Pre state, Synchronous, Server e off-line e, em seguida, clique em Parent Pipeline. 13. Copie o seguinte texto para a configuração Unsecure:
<MethodInfo><MethodName>RetrieveExchangeRate</MethodName><DeclaringType>Microsoft.Crm.ObjectModel.TransactionCurrencyService,Microsoft.Crm.ObjectModel</DeclaringType><InputMappings><Input><Name>TransactionCurrencyId</Name></Input><Input><Name>ExecutionContext()</Name></Input></InputMappings><OutputMappings><Field><Name>ExchangeRate</Name><Value>return-value</Value><ClrFormatter>System.Decimal</ClrFormatter></Field></OutputMappings></MethodInfo>
14. Clique em Update. 15. Clique, InternalOperation clique em Register, e em seguida, clique em Registrar Novo Passo novamente. 17. Conclua as etapas 8-14 novamente, mas desta vez para Child Pipeline no passo 12, em vez de Pipeline Pai.
Espero que este artigo seja do vosso agrado.
João Pedro Soares
CRM support Engineer PT