dynamics crm filtered view of the lookup is a very common demand properties, customize the view in 2011 when this is supplemented with the following sample code e.g.
<span style="font-size: 18px;">var pEntityName = "sc_stock";
var pViewDisplayName = "符合条件库存";
var </span><span style="font-size:18px;">pSotckControl</span><span style="font-size: 18px;">= Xrm.Page.getControl("new_stock");
var pFetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='sc_stock'><attribute name='sc_stockid'/>"
+ "<attribute name='sc_stocksn'/><attribute name='createdon'/>"
+ "<attribute name='sc_salebillamount'/><attribute name='sc_outputamount'/>"
+ "<attribute name='sc_bizbookresidue'/><attribute name='sc_bizbookamount'/>"
+ "<attribute name='sc_owner'/><attribute name='sc_storage'/>"
+ "<attribute name='sc_stocktype'/>"
+ "<attribute name='sc_uom'/>"
+ "<attribute name='sc_tank'/>"
+ "<attribute name='sc_product'/>"
+ "<attribute name='sc_bizunit'/>"
+ "<attribute name='sc_bizoperator'/>"
+ "<attribute name='sc_purchase'/>"
+ "<order attribute='sc_stocksn' descending='false'/>"
+ "<filter type='and'>"
+ "<condition attribute='sc_decreaseandoverflow' operator='eq' value='" + this.sc_isDecreaseandoverflow + "'/>"
+ "</filter>"
+ "</entity>"
+ "</fetch>"
var pLayoutXml = "<grid name='resultset' object='10122' jump='sc_stocksn' select='1' icon='1' preview='1'>"
+ "<row name='result' id='sc_stockid'>"
+ "<cell name='sc_stocksn' width='100'/><cell name='sc_purchase' width='100'/>"
+ "<cell name='sc_bizunit' width='100'/><cell name='sc_bizoperator' width='100'/>"
+ "<cell name='sc_product' width='100'/><cell name='sc_owner' width='100'/>"
+ "<cell name='sc_storage' width='100'/><cell name='sc_tank' width='100'/>"
+ "<cell name='sc_stocktype' width='100'/><cell name='sc_uom' width='100'/>"
+ "<cell name='sc_bizbookamount' width='100'/><cell name='sc_bizbookresidue' width='100'/>"
+ "<cell name='sc_outputamount' width='100'/><cell name='sc_salebillamount' width='100'/>"
+ "<cell name='createdon' width='125'/>"
+ "</row></grid>"
var id = "{CFD4B604-1C6A-4E61-B057-BA07620C0D46}";
pSotckControl.addCustomView(id, pEntityName, pViewDisplayName, pFetchXml, pLayoutXml, false);
pSotckControl.setDefaultView(id);</span>
Write a lot of inquiries XML, displaying XML is very cumbersome
2013 addCustomFilter added to this API,
<span style="font-size:18px;">Xrm.Page.getControl("new_stock").addPreSearch(function () {
var filter = "<filter type='and'>"
+ "<condition attribute='sc_decreaseandoverflow' operator='eq' value='" + this.sc_isDecreaseandoverflow + "'/>"
+ "</filter>";
Xrm.Page.getControl("new_stock").addCustomFilter(filter);
});</span>
Code is extremely simplified, XML uses only a condition condition and merely added to the default view search filter instead of adding a new custom view.Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed.
Reproduced in: https: //www.cnblogs.com/VicTang/p/4799578.html