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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans