首页 文章

CRM 2011使用outlook插件访问webcontext

提问于
浏览
0

我在网上找到了一些插件代码,使我能够获得插件中实体的实体ID和对象类型代码 . 该插件在activitypointer上的RetrieveMultiple上触发 . 代码让我获取当前正在查看的实体的id和目标代码(显示正在触发插件的活动网格) .

使用Web界面时,此代码可以正常工作 . 但是,我需要它也可以在Outlook预览窗格中工作,目前它没有 . Outlook预览窗格中的活动网格只显示“发生了错误” . 下面是插件用于从Web标头获取详细信息的代码 .

internal static Dictionary<string, string> GetHeaderFields(HttpContext webcontext, string objectTypeCode, string objectId)
    {
        Dictionary<string, string> fields = new Dictionary<string, string>();
        string callerentitytype = null;
        string callerentityidstring = null;
        try
        {
            // Activities Navigation Pane
            if (new List<string>(webcontext.Request.Params.AllKeys).Contains("oType"))
            {
                callerentitytype = webcontext.Request.Params["oType"];
                callerentityidstring = webcontext.Request.Params["oId"];
            }
            // Activities Sub Grid
            else
            {
                string requeststring = webcontext.Request.UrlReferrer.Query;
                requeststring = requeststring.Substring(1);

                string[] parts = requeststring.Split(new string[] { "=", "&" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < parts.Length - 1; i++)
                    if (parts[i].ToLower() == "otype" || parts[i].ToLower() == "etc")
                        callerentitytype = parts[i + 1];
                    else if (parts[i].ToLower() == "oid" || parts[i].ToLower() == "id")
                        callerentityidstring = parts[i + 1];
            }

            fields.Add(objectTypeCode, callerentitytype);
            fields.Add(objectId, callerentityidstring);
        }
        catch (Exception ex)
        {
            throw new Plugin.LoggableException(string.Format("Failed to obtain header information; {0}", ex.Message), ex.InnerException);
        }

        return fields;
    }

原因是webcontext.Request.UrlReferrer为NULL . 有没有其他地方我可以得到'呼叫'实体的这些信息? (不是触发插件的活动子网格,而是子网格所在的实际父实体) .

感谢您对此的任何帮助或指导 .

1 回答

  • 0

    这可能会奏效 . 返回的每个活动指针都应该是"regarding"相同的记录(如果在子网格中) . 如果你说第一个并检查aboutobjectid属性,那应该是一个实体引用,它将为你提供父代的逻辑名称和它的guid . 如果这样可行,它将适用于所有客户(理论上无论如何) .

相关问题