2017-01-03 29 views
0

我有一个表单中的客户类型字段,其模式名称为:myorg_customer。 (请注意,这是不是一个彻头彻尾的现成客户现场使用随CRM架构名称customerid。)Dynamics CRM 2016 - 使用表单参数设置自定义客户查询

我打开一个新的创建形式,用javascript如下:

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); 

但这样做后,页面更改为打开创建窗体,但我收到一条错误消息,指出“发生错误”。日志文件如下:通过设置customeridcustomeridname,并且customeridtype参数设置窗体上一个不折不扣的现成客户现场时

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: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"> 
    <ErrorCode>-2147220970</ErrorCode> 
    <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
    <KeyValuePairOfstringanyType> 
     <d2p1:key>CallStack</d2p1:key> 
     <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string"> 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; completedSynchronously)</d2p1:value> 
    </KeyValuePairOfstringanyType> 
    </ErrorDetails> 
    <Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #89B46272</Message> 
    <Timestamp>2017-01-03T13:41:22.8457002Z</Timestamp> 
    <InnerFault> 
    <ErrorCode>-2147220970</ErrorCode> 
    <ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
     <KeyValuePairOfstringanyType> 
     <d3p1:key>CallStack</d3p1:key> 
     <d3p1:value xmlns:d5p1="http://www.w3.org/2001/XMLSchema" i:type="d5p1:string"> 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)</d3p1:value> 
     </KeyValuePairOfstringanyType> 
    </ErrorDetails> 
    <Message>System.InvalidOperationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #46259303</Message> 
    <Timestamp>2017-01-03T13:41:22.8457002Z</Timestamp> 
    <InnerFault i:nil="true" /> 
    <TraceText i:nil="true" /> 
    </InnerFault> 
    <TraceText i:nil="true" /> 
</OrganizationServiceFault> 

同样的方法工作。

任何见解?

谢谢
Anindit

+0

代码对我来说很好。 2条建议。 1)看看[手动创建URL](https://msdn.microsoft.com/en-us/library/gg334375.aspx#BKMK_ExampleWindowOpen)有什么区别。 2)如果您在本地,则打开跟踪并查看跟踪输出是否显示可能有助于排除故障的任何信息。 – Polshgiant

回答

1

你需要添加myorg_customermyorg_customernamemyorg_customertype作为表单参数。你的错误信息是CRM的话说,形式参数是不允许的坏的方式...

这些都是guidelines from the Documentation

以下原则使用 表格上设置查找的值时应用一个查询字符串参数:

  1. 对于简单的查找,您必须设置值和要在查找中显示的文本。使用带有名称的后缀“name”来设置文本的值。

    请勿使用任何其他参数。

  2. 对于客户和所有者查找,您必须按照您为简单查找设置值和名称的方式来设置值和名称。另外,您必须使用后缀“type”来指定实体的类型。允许值包括账户,联系人,系统用户和团队。

  3. 您无法设置partylist或关于查找的值。

我会确保你使用的是实际的客户字段类型,而不仅仅是一个联系人参考。我还要确保它不是一个关于或是一个partylist。如果是这样,您需要定义与CRM查找不匹配的参数值(例如,添加下划线myorg_customer_id,myorg_customer_namemyorg_customer_type),然后在onload上编写代码以读取这些参数并填充正确的字段。

+0

从表单属性>参数中,我添加了'myorg_customer'(作为UniqueId),'myorg_customername'(作为SafeString)和'myorg_customertype'(作为EntityType和作为两个不同时间的SafeString)。但我仍然面临同样的问题。 –

相关问题