web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

addPresearch on subgrid not working with query that contains parameter

(0) ShareShare
ReportReport
Posted on by 121

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

I have the same question (0)
  • Suggested answer
    Aditya Profile Picture
    260 on at

    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>";

  • Creative.T Profile Picture
    12 on at
    Hey, how do you get the subgridLookup in you working code?
     
    Thanks,

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
NeerajPawar Profile Picture

NeerajPawar 2

#2
jlattimer Profile Picture

jlattimer 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans