Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

ExecuteQuery on class but loose its current record

(0) ShareShare
ReportReport
Posted on by 592

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,

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: ExecuteQuery on class but loose its current record

    Yes, research method will be sufficient.

    Thanks,

    Girish S.

  • Voltes Profile Picture
    Voltes 592 on at
    RE: ExecuteQuery on class but loose its current record

    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

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: ExecuteQuery on class but loose its current record

    Hi Lars Volt,

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

    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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans