2011-11-03 99 views
0

我已經寫了這個共同的功能基本上克隆形式的屬性,並將其傳遞到自己......無法通過extraqs參數CRM通過一個帳戶類型2011

/* 
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錯誤試圖反序列化對象,因爲它沒有一個類型集,導致空指針錯誤。

任何想法如何讓這個工作?

編輯:打開這個例外,它列出了regardingobjectidtype作爲無效參數CRM服務器跟蹤記錄結果,即使它的SDK說,使用什麼(http://msdn.microsoft.com/en-us/ library/gg334375.aspx),如果我通過除參數以外的所有內容,則會在CRM javascript中獲得javascript異常,因爲typename爲null。

[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) 
+0

可以調試它,並找出導致錯誤(使用一個賬戶屬性時)行 – glosrob

+0

當我使用的帳戶屬性,它給了我一個CRM服務器錯誤,而不是客戶端腳本錯誤,沒有任何信息。如果爲參數指定了無效值,則會得到同樣的確切錯誤。 – Daryl

回答