2015-06-17 20 views
0

Dyanamics crm 2015 sp 1,拋出異常「無法獲取未定義或空引用的屬性」修剪「設置查找值。動態crm 2015通過錯誤,同時設置字段中的值

  • 客戶編號有三個特性,即ID,姓名和LogicalName
  • 場「new_customerprofileid」被填充了,但是的setValue()函數拋出錯誤
  • 錯誤的位置是在global.ashx,有一條線b.trim其中通過錯誤。

代碼:

var Entity = RetrieveEntityById(Id, "SalesOrder"); 
if (Entity != null) { 
    var CustomerId = Entity.CustomerId; 
    if (CustomerId != null) 
     if (Xrm.Page.getAttribute("new_customerprofileid") != null) 
      Xrm.Page.getAttribute("new_customerprofileid").setValue([{ id: CustomerId.Id, name: CustomerId.Name, entityType: CustomerId.LogicalName }]); 
} 

一個解決方法是將線(.setValue( 「」))在try catch塊。

var Entity = RetrieveEntityById(Id, "SalesOrder"); 
    if (Entity != null) { 
     var CustomerId = Entity.CustomerId; 
     if (CustomerId != null) 
      if (Xrm.Page.getAttribute("new_customerprofileid") != null) 
       try { 
        Xrm.Page.getAttribute("new_customerprofileid").setValue([{ id: CustomerId.Id, name: CustomerId.Name, entityType: CustomerId.LogicalName }]); 
       } catch (ex) { } 

    } 

請回答是否有人爲此錯誤達成其他修復程序。

+0

您正在使用哪個互聯網瀏覽器?版本是多少? –

+0

IE 11.0.9600.17842 –

+0

您是否確定'CustomerId'包含您期望的字段? –

回答

0

系統嘗試修剪輸入值,但其中至少有一個是null而不是String。我想這意味着setValue字典中提供的值之一爲空:CustomerId.NameCustomerId.LogicalName。您可能會排除這些數據集,或者您可能希望將它們的值設置爲空字符串。

+1

似乎對我有效的回答,任何人低估了分享想法的關懷? – Koliat

0

我收到了同樣的問題。就我而言,本地CRM .js試圖訪問正在設置的查找值上名爲「type」的屬性,然後調用.trim導致b.trim未定義。 「類型」不是文檔說的需要設置的屬性,所以我懷疑CRM中存在一個錯誤,儘管試圖準確追蹤它發生的原因一直很困難。

我試着將屬性「類型」設置爲實體的對象類型代碼,但是這似乎會導致其他問題同樣難以弄清楚。

當我設置id,name和entityType時,我發現捕捉異常是迄今爲止最好的解決方案。我很可能會向MS提交一張門票來看看這個問題。