title: Dynamics CRM 2016 - Set custom Customer lookup using form parameters
body: <p>I have a Customer type field in a form with the schema name: <code>myorg_customer</code>. (Note that this is <strong>not</strong> an out-of-the-box customer field with schema name <code>customerid</code> that comes with CRM.)</p>
  
  <p>I am opening a new Create form using javascript as follows:</p>
  
  <pre><code>var customer = [
                  {
                      id: "571A6CE5-3EBC-4672-A164-D8F9654D4FCF",
                      name: "TestContact"
                  }
              ];
  parameters['myorg_customer'] = customer[0].id;
  parameters['myorg_customername'] = customer[0].name;     
  parameters['myorg_customertype'] = "contact" // since my customer is a contact instead of an account.
  
  parent.Xrm.Utility.openEntityForm("myorg_myentity", null, parameters);
  </code></pre>
  
  <p>But after doing so, the page changes to open the Create form but I get an error message saying "An error has occurred". The log file is as follows:</p>
  
  <pre><code>Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #89B46272Detail: 
  &lt;OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"&gt;
    &lt;ErrorCode&gt;-2147220970&lt;/ErrorCode&gt;
    &lt;ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"&gt;
      &lt;KeyValuePairOfstringanyType&gt;
        &lt;d2p1:key&gt;CallStack&lt;/d2p1:key&gt;
        &lt;d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string"&gt;   at System.Web.UI.Page.HandleError(Exception e)
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
     at System.Web.UI.Page.ProcessRequest()
     at System.Web.UI.Page.ProcessRequest(HttpContext context)
     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;amp; completedSynchronously)&lt;/d2p1:value&gt;
      &lt;/KeyValuePairOfstringanyType&gt;
    &lt;/ErrorDetails&gt;
    &lt;Message&gt;System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #89B46272&lt;/Message&gt;
    &lt;Timestamp&gt;2017-01-03T13:41:22.8457002Z&lt;/Timestamp&gt;
    &lt;InnerFault&gt;
      &lt;ErrorCode&gt;-2147220970&lt;/ErrorCode&gt;
      &lt;ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"&gt;
        &lt;KeyValuePairOfstringanyType&gt;
          &lt;d3p1:key&gt;CallStack&lt;/d3p1:key&gt;
          &lt;d3p1:value xmlns:d5p1="http://www.w3.org/2001/XMLSchema" i:type="d5p1:string"&gt;   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.Controls.AppPage.ValidatePageParameters()
     at Microsoft.Crm.Application.Controls.AppPage.OnInit(EventArgs e)
     at System.Web.UI.Control.InitRecursive(Control namingContainer)
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)&lt;/d3p1:value&gt;
        &lt;/KeyValuePairOfstringanyType&gt;
      &lt;/ErrorDetails&gt;
      &lt;Message&gt;System.InvalidOperationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #46259303&lt;/Message&gt;
      &lt;Timestamp&gt;2017-01-03T13:41:22.8457002Z&lt;/Timestamp&gt;
      &lt;InnerFault i:nil="true" /&gt;
      &lt;TraceText i:nil="true" /&gt;
    &lt;/InnerFault&gt;
    &lt;TraceText i:nil="true" /&gt;
  &lt;/OrganizationServiceFault&gt;
  </code></pre>
  
  <p>The same method works when setting an out-of-the-box customer field on a form by setting the <code>customerid</code>, <code>customeridname</code>, and <code>customeridtype</code> parameters.</p>
  
  <p>Any insights?</p>
  
  <p>Thanks,<br/>
  Anindit</p>