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

Announcements

No record found.

News and Announcements icon
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,833 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,833 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

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 509 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans