Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to select the records after filter by selection?

(0) ShareShare
ReportReport
Posted on by 925

Hi All,

I have requirment to update a field after filter..

say, we have a grid with records, we apply filter by selection .. Now what i want to do is,, i want to select this filtered records and update a field ..

how to select this filtered records??

Pls Advice

*This post is locked for comments

  • Mea_ Profile Picture
    60,278 on at
    RE: How to select the records after filter by selection?

    Hey Rusty,

    As I said in my initial reply you can use getFirst(), getNext(), please look at sniped proposed by Hariharan S.

    Second option is to use query from form and iterate it, please find example below:

    QueryRun qr = new QueryRun(myTable_ds.queryRun().query());
    
    while (qr.next())
    {
        myTable = qr.get(tableNum(myTable));
    }


    Now when you have a record you can select it for update and modify, delete or do whatever you need.

  • Verified answer
    Hariharans87 Profile Picture
    1 on at
    RE: How to select the records after filter by selection?

    To get all values even filtered records, you can the same code, but no need to pass the value to the datasource.getFirst() method.

    Try the below code to get all values

    MyTable myTable;
    
    myTable = MyTable_ds.getFirst();
    while(myTable)
    {
    	info(strFmt('%1', myTable.RecId));
    	myTable = MyTable_ds.getNext();
    }


  • ThivaKar Profile Picture
    925 on at
    RE: How to select the records after filter by selection?

    Hi ievgen,, Can you share more code .. ? I am confused ..

    while select forUpdate MyField from myTable
                where  myTable.MyField == NoYes::Yes
    {
    
        myTable.MyField= NoYes::No;
        myTable.update();
    }


    As you mentioned to use queryRun, where i have to make the changes..
    Pls Advice

  • Suggested answer
    Mea_ Profile Picture
    60,278 on at
    RE: How to select the records after filter by selection?

    Hey Rusty,

    There are 2 queries on the form : initial query and current query (filtered)

    You can get filtered query using this code :

    MyDataSource_ds.queryRun().query()

    now you can iterate query using query run to get all filtered records.

  • ThivaKar Profile Picture
    925 on at
    RE: How to select the records after filter by selection?

    And i dont want to select the multiple records.. If i want to select the multiple  records and update it , i have the answer in my previous post https://community.dynamics.com/ax/f/33/t/208267 where i got the answer with your help..

    Here what i am trying to do is to select the records that are already filtered by FilterbyField or FilterBySelection..

  • ThivaKar Profile Picture
    925 on at
    RE: How to select the records after filter by selection?

    Hi ievgen,

    MyTable myTable,myTable1;

    ;

    myTable = MyTable_ds.getFirst(true);

    while i debug it , no record is selected..

    Pls advice

  • Mea_ Profile Picture
    60,278 on at
    RE: How to select the records after filter by selection?

    Hi Rusty,

    You can use formDataSource.getFirst(), getNExt() to loop through records

    Please check this blog post community.dynamics.com/.../loop-through-record-from-data-source-ax-2012 to find code snippet or this http://daxmusings.codecrib.com/2013/01/multi-select-on-form-datasource-grid.html

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February 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... 293,272 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,931 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans