Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to pass an account type via extraqs parameters in CRM 2011
    text
    copied!<p>I've written this common function to basically clone the attributes on a form, and pass them into itself...</p> <pre><code>/* 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&amp;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 &lt; attributes.length; i++) { qs = CommonLib.getExtraQS(attributes[i]); if (qs.length &gt; 0) { qsParams += qs + "&amp;"; } } //end for // Remove extra &amp; qsParams = qsParams.substring(0, qsParams.length - 1); window.open("/" + Xrm.Page.context.getOrgUniqueName() + "/" + url + "&amp;extraqs=" + encodeURIComponent(qsParams), windowName, features, false); }, /* returns the extraqs value for the attribute, non-encodURIComponent-ed */ getExtraQS: function (attribute) { var extraQS = ""; if (attribute != null &amp;&amp; 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 &amp;&amp; value.length &gt; 0) { value = value[0]; extraQS = name + "=" + value.id + "&amp;" + name + "name=" + value.name; switch(value.typename){ case 'account': case 'contact': case 'systemuser': case 'team': extraQS += "&amp;" + 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; } </code></pre> <p>Everything works fine unless I try to pass an attribute of type <code>account</code>. I get the standard "Error. An error has occurred." If I skip the second switch statement, then I don't get a CRM Sever error, but a CRM javascript error attempting to deserialize the object because it doesn't have a type set, which results in a null pointer error.</p> <p>Any ideas how to get this to work?</p> <p>Edit: Turning on CRM server trace logging results in this exception which lists the regardingobjectidtype as an invalid parameter, even though it's exactly what the SDK says to use (http://msdn.microsoft.com/en-us/library/gg334375.aspx), and if I pass everything but that parameter, I get a javascript exception in the CRM javascript because the typename is null.</p> <pre><code>[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) &gt;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&amp;etc=4212&amp;abc_category=9&amp;abc_contactmade=false&amp;abc_pointofcontactid=%7b7E599729-1923-E011-858E-005056BB527B%7d&amp;abc_pointofcontactidname=Human%20Resources&amp;abc_result=11&amp;ownerid=%7bCAA79C99-0E9C-DF11-9D85-005056BB728E%7d&amp;owneridname=Rachel%20Richardson&amp;owneridtype=systemuser&amp;pagemode=iframe&amp;regardingobjectid=%7b58949706-1923-E011-858E-005056BB527B%7d&amp;regardingobjectidname=Cold%20Emails%20-%20016&amp;regardingobjectidtype=account&amp;sitemappath=Workplace%7cMyWork%7cnav_dashboards&amp;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&amp;etc=4212&amp;abc_category=9&amp;abc_contactmade=false&amp;abc_pointofcontactid=%7b7E599729-1923-E011-858E-005056BB527B%7d&amp;abc_pointofcontactidname=Human%20Resources&amp;abc_result=11&amp;ownerid=%7bCAA79C99-0E9C-DF11-9D85-005056BB728E%7d&amp;owneridname=Rachel%20Richardson&amp;owneridtype=systemuser&amp;pagemode=iframe&amp;regardingobjectid=%7b58949706-1923-E011-858E-005056BB527B%7d&amp;regardingobjectidname=Cold%20Emails%20-%20016&amp;regardingobjectidtype=account&amp;sitemappath=Workplace%7cMyWork%7cnav_dashboards&amp;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&amp;pagetype=entityrecord&amp;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) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload