Dynamics crm 2011 更新消息post Operation中的PostEntityImage根本没有键

Dynamics crm 2011 更新消息post Operation中的PostEntityImage根本没有键,dynamics-crm-2011,Dynamics Crm 2011,我已经通过Visual Studio中的CRM工具注册了某个实体(在后期操作中)更新消息的插件,并且还注册了该插件的后期图像,如下所示: 这是我的代码: 受保护的void ExecutePottopOrtUnityUpdate(LocalPluginContext 本地上下文) { if (localContext == null) { throw new ArgumentNullException("localContext");

我已经通过Visual Studio中的CRM工具注册了某个实体(在后期操作中)更新消息的插件,并且还注册了该插件的后期图像,如下所示:

这是我的代码:

受保护的void ExecutePottopOrtUnityUpdate(LocalPluginContext 本地上下文) {

        if (localContext == null)
        {
            throw new ArgumentNullException("localContext");
        }




        // TODO: Implement your custom Plug-in business logic.
        IPluginExecutionContext context = localContext.PluginExecutionContext;

        Entity postImage = (Entity)context.PostEntityImages["PostImage"];

}

但是它抛出了一个错误,说PostEntityImages中根本没有键。我调试了插件,发现里面根本没有键


你能帮帮我吗?

看看你的代码,你必须检索机会的实际实体:试试这个

 try
 {

Entity postOpportunityService = (Entity)context.PostEntityImages["PostImage"];

// Opportunity service's parent opportunity lookup reference
EntityReference opportunityReference = (EntityReference)postOpportunityService.Attributes["mpc_opportunityid"];

// Columns to be retrieved for opportunity (aka. columns to be edited)
ColumnSet opportunityColumnSet = new ColumnSet(new string[] { "estimatedvalue", "mpc_estoneoffinvoicing", "mpc_estinvoicingperyear" });

// Retrieve actual opportunity entity
Entity opportunity = service.Retrieve(opportunityReference.LogicalName, opportunityReference.Id, opportunityColumnSet);             

}

catch (FaultException<OrganizationServiceFault> ex) {   tracingService.Trace("FaultException", ex.ToString()); }
试试看
{
实体postOpportunityService=(实体)上下文。PostEntityImages[“PostImage”];
//Opportunity服务的父Opportunity查找引用
EntityReference opportunityReference=(EntityReference)postOpportunityService.Attributes[“mpc_opportunityid”];
//要为opportunity检索的列(也称为要编辑的列)
ColumnSet opportunityColumnSet=新列集(新字符串[]{“estimatedvalue”、“mpc_Estoneoffining”、“mpc_EstinVoicengPeryear”});
//检索实际商机实体
实体opportunity=service.Retrieve(opportunityReference.LogicalName、opportunityReference.Id、opportunityColumnSet);
}
catch(FaultException ex){tracingService.Trace(“FaultException”,ex.ToString());}

谢谢……这看起来很可笑,但重新启动crm服务器解决了问题,现在预映像和后映像已填充!嗯,是的,有时候我也会这样。回收crm应用程序池可以做到这一点,这是一个良好的做法:D