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 :
Finance | Project Operations, Human Resources, ...
Answered

Query Run using x++

(0) ShareShare
ReportReport
Posted on by 100

Hello All ,

My requirement is to get the filters applied on the grid by the user , I want to save the where condition in one of my field .

I need all the filter applied by the user in a grid on a button clicked to save the where condition.

Please help me in this 

I have the same question (0)
  • nunomaia Profile Picture
    25 Moderator on at

    Check is method queryRunQueryBuildDataSource() should your requirements  

  • mark wilson Profile Picture
    100 on at

    I just want to save the where condition in my field from queryRun() , how to achieve that ?

  • Verified answer
    Mariano Gracia Profile Picture
    on at

    What is the purpose of that requirement?, translate a queryrun object into a select statement in order to take the where condition sounds a bit odd, beside of this it won't be easy if there are multiple datasources, instead of that, why don't just you pack the queryrun object and save it into a container field from your record?, later you can read that container and use it again to build a new queryrun object, you can even prompt that queryrun so you can show the filters in the screen

  • mark wilson Profile Picture
    100 on at

    Thanks Mariano gracia , Sounds really cool .

    It got all the point except one .

    I will pack the query run and save , Now how will I use the query to filter the grid , Can u give me some blogs or any line of code that packs and unpacks the queryRun

  • Verified answer
    Martin Dráb Profile Picture
    237,926 Most Valuable Professional on at

    Use pack() method to pack an instance and the constructor to unpack it. For example:

    container packed = queryRun.pack();
    QueryRun qrUnpacked = new QueryRun(packed);

  • mark wilson Profile Picture
    100 on at

    Martin , just one more thing , how will I create query in execute query using queryRun() above ??

  • Martin Dráb Profile Picture
    237,926 Most Valuable Professional on at

    Why do you want to create another query every time when the current query gets executed? It doesn't look like the right place to me. I believe that you want to change the query at some point (e.g. when pressing a button) and then just let the system use this query in the usual way.

    It'll help if you explain your business scenario.

  • mark wilson Profile Picture
    100 on at

    On button press will save the query , We have transaction table , in which lakhs of records are there , the user want to see only the records which he has previously applied filter on.

  • Martin Dráb Profile Picture
    237,926 Most Valuable Professional on at

    Can't you simply used saved views for this purpose? Or maybe tiles and/or workspaces defined by users.

    If developing a custom solution is necessary, realize that the requirement "the user want to see only the records which he has previously applied filter on" means that the user must be able to select the saved query. Analyze the requirements to understand when it'll be done. When the selection is made, apply the query and then let the system use it. Trying to apply the query again and again on executeQuery() sounds redundant and it would prevent users from adding extra ranges and sorting, because the query would be always changed to the saved one.

  • mark wilson Profile Picture
    100 on at

    Hi Martin , The client don't wanna use saved views .

    He will update the query everytime whenever the filters will changed on the grid .

    I am able to save the query in a container field , But i am not able to apply the exact saved query on execute query .

    And also I have to apply several records saved query on a grid in order to get the records of a particular group of person .

    Martin , can you please tell me how to achieve this .

    Basically what the user applies on grid is Query Filter , not the range , right ?

    My query is creating or adding filters in debugger ,

    But how will I apply this to current datasource ,

    Pls help me.in this ?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans