Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Setting focus\highlighting particular grid row in dynamics AX

Posted on by 110

Hi,

I have a requirement where I have to set focus (highlight) on a particular sales order record in the form's grid (FormB).

FormB receives salesId (of the recod to be selected) as an args parameter (from FormA).

I have written below code in FormB's init() method, but can't get it to work. Could someone please suggest:

public void init()
{
    SalesTable sl;
    super();
    sl = SalesTable::find('SO-XXXXXX');
  
    salesTable_ds.research();
    salesTable_ds.findRecord(sl);

}
 

*This post is locked for comments

  • Verified answer
    RE: Setting focus\highlighting particular grid row in dynamics AX

    findRecord() is one of the ways to go.

    You are using it a bit wrong however.

    You are trying to find a record in the datasource, which is right. But you are calling it too early, the data has not been retrieved yet (it happens in executeQuery() of the datasource)

    However, findRecord() is very slow, and Microsoft generally speaking considers its use a bad practice.

    Consider, instead, using the lookupRecord() method on the args class when calling FormB

    stackoverflow.com/.../dynamics-ax-2009-go-to-main-table-form-how-to-select-the-default-row

  • Suggested answer
    Bashir Ahmad Profile Picture
    Bashir Ahmad 5,248 on at
    RE: Setting focus\highlighting particular grid row in dynamics AX

    You can create an extra table buffer variable and fill it with the record you want to set focus on then run the following line of code: yourDataSource_ds.findRecord(yourNewTableBuffer); so if for example we are in SalesTable and yournewTableBuffer has the record with sales id: so_01122 then the grid focus will go on that record.

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans