2014-07-21 45 views

回答

2

我最近遇到了來自客戶端的相同請求,在一些不成功的搜索之後,我們決定替換帶有帳戶的表單上的字段。即使有客戶提交,在CRM中默認存在兩個單獨的字段來存儲帳戶和聯繫人。

因此,我們只是刪除/隱藏窗體上的客戶字段並添加了帳戶字段。填充帳戶字段後,客戶字段會自動填充。

希望這會有所幫助。

0

這是我所做的設置客戶查找只顯示聯繫記錄。

function Form_OnLoad() 
... 
preFilterLookup(); 
.. 
} 


function preFilterLookup() { 
Xrm.Page.getControl("customerid").addPreSearch(addLookupFilter); 
} 

function addLookupFilter() { 

document.getElementById("customerid_i").setAttribute("lookuptypenames", "contact:2:Contact"); 
document.getElementById("customerid_i").setAttribute("lookuptypes", "2"); 
} 

如果你想要一個過濾器添加到記錄:

function addLookupFilter() { 

document.getElementById("customerid_i").setAttribute("lookuptypenames", "contact:2:Contact"); 
document.getElementById("customerid_i").setAttribute("lookuptypes", "2"); 

var account = Xrm.Page.getAttribute("aux_account").getValue(); 

if (account != null) { 

    var filter = "<filter type='and'>" + "<condition attribute='parentcustomerid' operator='eq' value='" + account[0].id + "' /></filter>"; 
    Xrm.Page.getControl("customerid").addCustomFilter(filter); 
} 

}

所以,我對我所做的2011年CRM遷移到2013年的變化是:

_i當你得到的元素:document.getElementById("customerid_i")

使用新方法:addPreSearchaddCustomFilter

您可以在msdn文檔中查看這些文件,並輕鬆更改代碼以僅顯示帳戶。

相關問題