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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Query filter is not working on View Datasource

(0) ShareShare
ReportReport
Posted on by 487

Hi Community Experts,

I have developed a below form using Custom view as DataSource. On this form I have requirement to filter record in grid on click of Tile button with different ranges.

I have tried below code, but it is not working. Please guide me with the better solution to develop this kind of form or else let me know if anything is wrong in the query range code.

public void executeQuery()
{
    Query   Query;

    this.query().dataSourceTable(tableNum(AllSOLinesView)).clearRanges();

    if(delaysSoLinesClicked)
    {
        this.query().dataSourceTable(tableNum(NCABAllSOLinesView)).addRange(fieldNum(NCABAllSOLinesView,ShippingDateConfirmed)).value(queryValue(today()));
    }
    else if(UnConfirmedSoLinesClicked)
    {
        this.query().dataSourceTable(tableNum(NCABAllSOLinesView)).addRange(fieldNum(NCABAllSOLinesView,ShippingDateConfirmed)).value(queryValue("1900-01-01 00:00:00.000"));
    }
    else
    {
        super();
    }
}

pastedimage1671281159023v1.pngpastedimage1671280023925v3.png


I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,829 Moderator on at

    Hi vijay,

    Instead of executeQuery method add your logic in the clicked method of each tile button and after that call the datasource executequery and refresh method.

    I am not sure whether you have clicked method for tile button. Check whether its there.

    If tile doesn't have clicked method then you need to rethink your design.

    Also you have added the filter text box above tiles. Instead of adding range upon button click of tile you can give a text box or check box to allow user to select. Based on the selection and clicking on refresh button you can add a range to it.

    Thanks,

    Girish S.

  • Vijay Yelmame VY Profile Picture
    487 on at

    Hi Girish,

    Thank for the reply.

    I already called same method from Clicked method, even in query variable I am able to see the filter as well but not seen grid is filtered. I am not sure if we can add range on view or not ?
     

    public void clicked()
    {
        super();
        dueSoLinesClicked = true;
        NCABAllSOLinesView_ds.executeQuery();
    }

    public void clicked()
    {
        super();
        delaysSoLinesClicked = true;
        NCABAllSOLinesView_ds.executeQuery();
    }

  • Verified answer
    GirishS Profile Picture
    27,829 Moderator on at

    You cannot add the super of executeQuery in the if condition. Remove the super from if condition and check.

    Also make sure you have added code above super call.

    Thanks,

    Girish S.

  • Suggested answer
    Vijay Yelmame VY Profile Picture
    487 on at

    Hi Girish,

    Thank you for pointing the correct mistake.

    I am now able to filter.

    public void executeQuery()
    {
        this.query().dataSourceTable(tableNum(NCABAllSOLinesView)).clearRanges();
    
        if(delaysSoLinesClicked)
        {
            this.query().dataSourceTable(tableNum(NCABAllSOLinesView)).addRange(fieldNum(NCABAllSOLinesView,ShippingDateConfirmed)).value(queryValue(today()));
        }
        else if(UnConfirmedSoLinesClicked)
        {
            this.query().dataSourceTable(tableNum(NCABAllSOLinesView)).addRange(fieldNum(NCABAllSOLinesView,ShippingDateConfirmed)).value(queryValue(dateNull()));
        }
        else if(dueSoLinesClicked)
        {
            this.query().dataSourceTable(tableNum(NCABAllSOLinesView)).addRange(fieldNum(NCABAllSOLinesView,ShippingDateConfirmed)).value(queryValue(today()));
        }
    
        super();
    
        delaysSoLinesClicked        = false;
        UnConfirmedSoLinesClicked   = false;
        dueSoLinesClicked           = false;
    }

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 663 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 289 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 232 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans