Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Query filter is not working on View Datasource

(0) ShareShare
ReportReport
Posted on by 438

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


  • Suggested answer
    Vijay Yelmame VY Profile Picture
    Vijay Yelmame VY 438 on at
    RE: Query filter is not working on View Datasource

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

  • Verified answer
    GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 on at
    RE: Query filter is not working on View Datasource

    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.

  • Vijay Yelmame VY Profile Picture
    Vijay Yelmame VY 438 on at
    RE: Query filter is not working on View Datasource

    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();
    }

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 on at
    RE: Query filter is not working on View Datasource

    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.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,861 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,540 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans