web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

ExecuteQuery on class but loose its current record

(0) ShareShare
ReportReport
Posted on by 596

Hi, 

I have a form that inside contain a Grid, listing my records. I created a class that works from a button at the top of the form that processing something by first get the current record on the grid. However, problem arise when I want to refresh my form (also the grid), as I'm using this code : 

internal final class My_ProcessToClear
{
    static void main(Args   _args)
    {
        
        MyTable   myTable = _args.record();
        .
        .    
        .
        FormDataSource fds = _args.record().datasource();
        fds.executeQuery();
        fds.refresh();
    }

}

It looks that ExecuteQuery(), while get my updated data (since my process will update some fields in the form which contain 2 tables : header and detail), it will also change the pointer of the current record. Because right after this class executed, the form changed to display other record. Just to inform, form that code, MyTable is the header (example : recordNo. 5) so after the class, the header will show other record which is recordNo.1

Is there a way to point back to the current record ?

Thanks,

I have the same question (0)
  • GirishS Profile Picture
    27,829 Moderator on at

    Hi Lars Volt,

    Try calling fds.research(true) on your class to retain position selected of record.

    Thanks,

    Girish S.

  • Voltes Profile Picture
    596 on at

    Hi Girish,

    If I'm not mistaken, when using Research, we can eliminate the use of ExecuteQuery() and also Refresh(), is that true ? Which mean Research(true) only will be sufficient ?

    Thanks

  • Verified answer
    GirishS Profile Picture
    27,829 Moderator on at

    Yes, research method will be sufficient.

    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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 342 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans