Announcements
Hi, i want to add presearch on my subgrid based on optionset value. Basically the code is working fine. But i have a little modification within the code. And the code start not working as i expected. Here is the code
subgridLookup.addPreSearch(function() {
//Standard logic to build up the filter query string
var problemType = Xrm.Page.getAttribute("lnkt_problemtype").getValue();
var filterQuery1= "<filter type='and'>"+"<condition attribute='lnkt_problemtype' operator='eq' value='"+problemType+"' />"+"</filter>";
var filterQuery2= "<filter type='and'>"+"<condition attribute='lnkt_problemtype' operator='eq' value='180000000' />"+"</filter>";
//filterQuery = "<filter type='and'.....></filter>";
//..
//..
//Standard call to add filter to the lookup control
subgridLookup.addCustomFilter(filterQuery1);
//alert(filterQuery1);
});
This function work if i use filterQuery2. But if i use filterQuery1 the look up on the subgrid display no record. Something wrong within this code ?
Also i have make sure that variable problemType contain optionsetvalue too
*This post is locked for comments
First of all use formContext instead of Xrm.Page (you can follow the link sachinbansal.blog/.../) and check for null also
var problemType = formContext.getAttribute("lnkt_problemtype").getValue()!=null?formContext.getAttribute("lnkt_problemtype").getValue() : null;
If it doesn't work then try out by removing the ' symbol as optionset will give a Number.
var filterQuery1= "<filter type='and'>"+"<condition attribute='lnkt_problemtype' operator='eq' value="+problemType+" />"+"</filter>";
André Arnaud de Cal...
294,161
Super User 2025 Season 1
Martin Dráb
232,942
Most Valuable Professional
nmaenpaa
101,158
Moderator