2017-01-03 104 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)。但我仍然面臨同樣的問題。 –

相關問題