Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to select the records after filter by selection?

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
    Mea_ 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
    Hariharans87 4,971 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
    ThivaKar 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
    Mea_ 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
    ThivaKar 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
    ThivaKar 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
    Mea_ 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans