Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

addCustomFilter and addCustomView , DefaultView ,setDefaultView,addPreSearch,removePreSearch in Lookup control methods and events

Posted on by 50
function OnLoad() {
	var fetchXml;
	var pattern = "Nam";
	function setCustomView() {
		var viewId = Xrm.Page.getControl("SubSV").getDefaultView();
		var entityName = "hoang_sinhvien";
		var viewDisplayName = "Filtered SinhVien";

		fetchXml="<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" distinct=\"false\"> "+
				 "<entity name=\"hoang_sinhvien\"><attribute name=\"hoang_name\" /><order attribute=\"hoang_name\" descending=\"false\" />"+
				 "<link-entity name=\"hoang
_dateofbirth\" form=\"hoang_dateofbirth\" to=\"hoang_dateofbirth\" alias=\"aa\"><filter type=\"and\">"+
				 
				 "<condition attribute=\"hoang_gender\" operator=\"eq\" value\""+
				 pattern + "\" /></filter></link-entity>" + 
				 "<attribute name=\"hoang_name\" /><attribute name=\"hoang_dateofbirth\" /><attribute name=\"hoang_sinhvienid\" /></entity></fetch>";

		var layoutXml ="<grid name=\"resultset\" object=\"10010\" jump=\"hoang_name\" select=\"1\" preview=\"1\" icon=\"1\">" +
				"<row name=\"result\" id=\"hoang_sinhvienid\"><cell name=\"hoang_name\" width=\"150\"/><cell name=\"hoang_dateofbirth\" width=\"100\"/>"+
				"<cell name=\"hoang_name\" width=\"100\"/></row></grid>";
		Xrm.Page.getControl("SubSV").addCustomView(viewId,entityName,viewDisplayName,fetchXml,layoutXml,true);      
	}
}

Hello, I'm a newbie, my problem is how to:
I am trying to create addCustomFilter and addCustomView ... as follows


I have a reference to this page: https://community.dynamics.com/crm/b/powerxrmblog/archive/2016/06/13/lookup-filtering-using-addcustomview 

I have a living entity. These include dateofbirth and gender fields
This is the fetchXML statement I want it to show only for male students and it worked but the viewDisplayName property does not appear in the Loop Up Record Look in box as shown below. Know where I am wrong in the code? the bottom and can make short of the tops of the code is not, Thank you!

aaqaqaqaqaaaa.png

*This post is locked for comments

  • Verified answer
    David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: addCustomFilter and addCustomView , DefaultView ,setDefaultView,addPreSearch,removePreSearch in Lookup control methods and events

    I think the problem might be that you're using the existing viewId value. When you call addCustomView, the viewId should be unique, so you should generate a new viewId

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans