无法通过CRM 2011中的附加参数传递帐户类型

Unable to pass an account type via extraqs parameters in CRM 2011

本文关键字:参数传递 类型 CRM 2011      更新时间:2023-09-26

我已经编写了这个通用函数,基本上是克隆表单上的属性,并将它们传递给自己…

/*
Opens a new window, copying the current page, and loading the new item with the current values
* Sample call *
var url = "main.aspx?etn=task&pagetype=entityrecord";
var features = 'location=no,status=yes,scrollbars=no,menubar=no,toolbar=no,width=900,height=600';
CommonLib.openClone(url, '_blank', features, Xrm.Page.getAttribute(null));
*/
openClone: function (url, windowName, features, attributes) {
    var qsParams = "";
    var qs;
    for (var i = 0; i < attributes.length; i++) {
        qs = CommonLib.getExtraQS(attributes[i]);
        if (qs.length > 0) {
            qsParams += qs + "&";
        }
    } //end for
    // Remove extra &
    qsParams = qsParams.substring(0, qsParams.length - 1);
    window.open("/" + Xrm.Page.context.getOrgUniqueName() + "/" + url + "&extraqs=" + encodeURIComponent(qsParams), windowName, features, false);
},
/*
returns the extraqs value for the attribute, non-encodURIComponent-ed
*/
getExtraQS: function (attribute) {
    var extraQS = "";
    if (attribute != null && attribute.getValue() != null) {
        // Set name value based on type and id
        switch (attribute.getAttributeType()) {
            case "lookup":
                var value = attribute.getValue();
                var name = attribute.getName();
                if (value != null && value.length > 0) {
                    value = value[0];
                    extraQS = name + "=" + value.id + "&" + name + "name=" + value.name;
                    switch(value.typename){
                        case 'account':
                        case 'contact':
                        case 'systemuser':
                        case 'team':
                            extraQS += "&" + name + "type=" + value.typename;
                        break;
                    }
                }
                break;
            case "datetime":
                extraQS = attribute.getName() + "=" + CommonLib.getCRMDateFormat(attribute.getValue());
                break;
            default:
                extraQS = attribute.getName() + "=" + attribute.getValue();
                break;
        }
    }
    return extraQS;
}

一切工作正常,除非我试图传递类型为account的属性。我得到标准的"错误"。发生了错误。"如果我跳过第二个switch语句,那么我不会得到一个CRM Sever错误,而是一个试图反序列化对象的CRM javascript错误,因为它没有类型集,这会导致空指针错误。

有什么办法让它工作吗?

编辑:打开CRM服务器跟踪日志记录导致此异常,该异常将regardingobjecdtype列为无效参数,即使它正是SDK所说的使用(http://msdn.microsoft.com/en-us/library/gg334375.aspx),如果我传递除该参数外的所有内容,我将在CRM javascript中获得javascript异常,因为typename为空。

[2011-11-04 08:27:53.961] Process: w3wp |Organization:306a6cd8-f599-df11-b324-005056bb527b |Thread:   14 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Error | ErrorInformation.LogError
at ErrorInformation.LogError()
at ErrorInformation..ctor(Exception exception, Uri requestUrl, Boolean logError)
at MainApplication.Application_Error(Object sender, EventArgs eventArguments)
at EventHandler.Invoke(Object sender, EventArgs e)
at HttpApplication.RaiseOnError()
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>MSCRM Error Report:
--------------------------------------------------------------------------------------------------------
Error: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Error Message: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Error Details: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source File: Not available
Line Number: Not available
Request URL: http://dev-crmapp03.abc.com/TestOrg/userdefined/edit.aspx?actualdurationminutes=1&etc=4212&abc_category=9&abc_contactmade=false&abc_pointofcontactid=%7b7E599729-1923-E011-858E-005056BB527B%7d&abc_pointofcontactidname=Human%20Resources&abc_result=11&ownerid=%7bCAA79C99-0E9C-DF11-9D85-005056BB728E%7d&owneridname=Rachel%20Richardson&owneridtype=systemuser&pagemode=iframe&regardingobjectid=%7b58949706-1923-E011-858E-005056BB527B%7d&regardingobjectidname=Cold%20Emails%20-%20016&regardingobjectidtype=account&sitemappath=Workplace%7cMyWork%7cnav_dashboards&subject=%2a%20Security%20Alarm%20Installer%20%2f%20Technician%20%2a%20%28St.Louis%29
Stack Trace Info: [InvalidOperationException: CRM Parameter Filter - Invalid parameter 'regardingobjectidtype=account' in Request.QueryString on page /TestOrg/userdefined/edit.aspx
The raw request was 'GET /TestOrg/userdefined/edit.aspx?actualdurationminutes=1&etc=4212&abc_category=9&abc_contactmade=false&abc_pointofcontactid=%7b7E599729-1923-E011-858E-005056BB527B%7d&abc_pointofcontactidname=Human%20Resources&abc_result=11&ownerid=%7bCAA79C99-0E9C-DF11-9D85-005056BB728E%7d&owneridname=Rachel%20Richardson&owneridtype=systemuser&pagemode=iframe&regardingobjectid=%7b58949706-1923-E011-858E-005056BB527B%7d&regardingobjectidname=Cold%20Emails%20-%20016&regardingobjectidtype=account&sitemappath=Workplace%7cMyWork%7cnav_dashboards&subject=%2a%20Security%20Alarm%20Installer%20%2f%20Technician%20%2a%20%28St.Louis%29' called from http://dev-crmapp03.abc.com/TestOrg/main.aspx?etn=task&pagetype=entityrecord&extraqs=subject%3D*%20Security%20Alarm%20Installer%20%2F%20Technician%20*%20(St.Louis)%26abc_category%3D9%26regardingobjectid%3D%7B58949706-1923-E011-858E-005056BB527B%7D%26regardingobjectidname%3DCold%20Emails%20-%20016%26regardingobjectidtype%3Daccount%26abc_pointofcontactid%3D%7B7E599729-1923-E011-858E-005056BB527B%7D%26abc_pointofcontactidname%3DHuman%20Resources%26ownerid%3D%7BCAA79C99-0E9C-DF11-9D85-005056BB728E%7D%26owneridname%3DRachel%20Richardson%26owneridtype%3Dsystemuser%26abc_contactmade%3Dfalse%26abc_result%3D11%26actualdurationminutes%3D1.]
at Microsoft.Crm.Application.ParameterFilter.ValidateParameter(HttpRequest request, ArrayList parameterCollection, String key, String value, ParameterSources source, EntityType pageEntityType, FormAdditionalAllowedParameters additionalAllowedParameters)
at Microsoft.Crm.Application.ParameterFilter.ValidateParameters(Page page, EntityType pageEntityType, Boolean alwaysEnableParameterChecking, FormAdditionalAllowedParameters formAdditionalAllowedParametersTemp)
at Microsoft.Crm.Application.ParameterFilter.ValidateParameters(Page page, EntityType pageEntityType, FormAdditionalAllowedParameters formAdditionalAllowedParametersTemp)
at Microsoft.Crm.Application.Controls.AppPage.ValidatePageParameters()
at Microsoft.Crm.Application.Controls.PageManager.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

好吧,我一定是弱智了…看起来我的查找是关于查找,而不是客户查找,并且根据我在问题中引用的SDK链接,CRM不支持通过extraqs设置此值。

CRM 2011:用URL参数
填充电子邮件实体表单字段