Skip to main content

Notifications

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

  • Creative.T Profile Picture
    12 on at
    addPresearch on subgrid not working with query that contains parameter
    Hey, how do you get the subgridLookup in you working code?
     
    Thanks,
  • Suggested answer
    Aditya Profile Picture
    260 on at
    RE: addPresearch on subgrid not working with query that contains parameter

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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,161 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,942 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans