Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to set first field on form load

(0) ShareShare
ReportReport
Posted on by 195

Hi there,

I would like the cursor to start in the ItemId field of the first sales line when I open up the SalesTable form. In firstField(), I have this:

public void firstField(int _flags=1)

{

   super(_flags);

   this.nextGroup();

}

My nextGroup() method looks like this:

void  nextGroup()

{

   info('In nextGroup()');

   if (!SalesLine::exist(salesTable.SalesId))

   {

       salesLine_ds.create();

   }

   salesLine_ItemId.setFocus();

}

When I open up the SalesTable form, I get the info message, then the cursor goes to the ItemId field, BUT THEN, the cursor goes to a field in the header.

How do I find out what is moving the cursor up there?

Thanks,

Tom

*This post is locked for comments

  • tomhv Profile Picture
    tomhv 195 on at
    RE: How to set first field on form load

    Thanks, Simon!  I fixed this by using the linkActive() method on the SalesLine data source.

  • Verified answer
    KLSI Profile Picture
    KLSI 40 on at
    RE: How to set first field on form load

    Hi,

    there are several reason for a changed focus in a form...

    However, to solve you issue, I would set the focus directly to the salesLine_ItemId control like this is done in salesLine_ds.create() (at least in AX 2012 R2 CU7). You could call salesLine_ItemId.setFocus() in SalesTable_ds.active() or linkActive(), depending on what you want to achive...

    Best regards

    Simon

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…

Vahid Ghafarpour – Community Spotlight

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

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans