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!
*This post is locked for comments
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156