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 :
Microsoft Dynamics AX (Archived)

How to select the records after filter by selection?

(0) ShareShare
ReportReport
Posted on by 931

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

I have the same question (0)
  • Mea_ Profile Picture
    60,284 on at

    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

  • ThivaKar Profile Picture
    931 on at

    Hi ievgen,

    MyTable myTable,myTable1;

    ;

    myTable = MyTable_ds.getFirst(true);

    while i debug it , no record is selected..

    Pls advice

  • ThivaKar Profile Picture
    931 on at

    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..

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    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
    931 on at

    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

  • Verified answer
    Hariharans87 Profile Picture
    3 on at

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


  • Mea_ Profile Picture
    60,284 on at

    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.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans