【问题标题】:Retrieve Current ID Crm Online在线检索当前 ID Crm
【发布时间】:2014-04-16 17:23:07
【问题描述】:
Entity title = new Entity();
title = service.Retrieve("incident",((Guid)((Entity)context.InputParameters["Target"]).Id), new ColumnSet("title"));

我正在使用此代码来获取事件的当前 ID,同时我正在关闭它! 但收到此错误:

插件意外异常(执行):FecharIncidente.Plugins.PostIncidenteClose:System.Collections.Generic.KeyNotFoundException:字典中不存在给定的键。

我的一个伙伴使用完全相同的代码并且正在开发他的 crm ! 一些帮助!?!

【问题讨论】:

    标签: dynamics-crm-2011 dynamics-crm crm dynamics-crm-online


    【解决方案1】:

    显然您的 InputParameters 集合没有“目标”键值。检查您正在使用的请求是否具有“目标”输入参数。

    if (context.InputParameters.Contains("Target") &&
        context.InputParameters["Target"] is Entity)
    {
        // Obtain the target entity from the input parameters.
        title = service.Retrieve("incident", ((Entity)context.InputParameters["Target"]).Id, new ColumnSet("title"));
    

    【讨论】:

    • E 已经尝试过你的方法,但同样的错误即将到来
    • @Nevesito 我还会检查您的插件注册与您的“伙伴”。看看你是否能发现任何差异。您确定是那条特定的行出错了吗?你怎么知道的?
    【解决方案2】:

    打赌你“目标”未包含在 InputParameters 中,导致 KeyNotFoundException - “给定的键不在字典中。”

    您可以像 Daryl 解释的那样检查目标,或者使用工作流中可用的上下文,就像这样......

    protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the context
            var context = executionContext.GetExtension<IWorkflowContext>();
            var title = new Entity();
            //context.PrimaryEntityName - should hold string incident
            //context.PrimaryEntityId - should hold your guid
            title = service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet("title"));
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多