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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Another setFocus() question

(0) ShareShare
ReportReport
Posted on by 6,609

Hello,

I have an existing post for a setFocus issue but not related to this particular post.

I've not worked with the frontend all that much. We have a custom form which contains a particular Real control. In a method on the form a calculated value is set to this control, then I call setFocus() to bring the focus to this control. All this working fine to this point. Where it falls apart is, with this control having the focus, I type in a different value and hit enter which should call modified() and recalculate the updated value. Instead the focus jumps to a different control. If I tab back to this field and change the value now, then the code kicks in and updates the value. 

Adding a breakpoint to the modified() for this control shows that it isn't called after the initial value change. 

Is there an additional parameter I need to set for this control prior to putting focus on it?

Thank you.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I too have this same issue where modified() is not being called after setting focus in the field. Only way to make it call modified() is clicking within the field first before hitting enter.

  • Iulian Cordobin Profile Picture
    8,201 on at

    Are the controls you are using bounded fields? Because I just tested with unbounded fields and it seems to work. Setting a value, setFocus(), modifying the value again, and hitting enter called (in my case) modified().

  • Community Member Profile Picture
    on at

    Hi Kbanh,

    Forms can be a bit of a nightmare if you do not know where to look.

    For example, before calling modified, it will call validate, and if this is data bound, it will also call the validate / modified on the data source.

    In a simple scenario, the setFocus will work.

    You will probably find that something is conflicting with your will in an override method that is being called earlier in the process.

    Hope this helps ;)

  • Community Member Profile Picture
    on at

    For my situation, all of the string edit controls are unbounded. I've set a breakpoint in my modified method and tried it both ways. Only time the breakpoint is hit is when I click with in the field then scan input into the field. We are on AX 2012 RTM CU3.

  • Community Member Profile Picture
    on at

    Hi Kelinder,

    The override sequence is something like - Task / SelectControl / Validate / Modified

    There are more than these, but I would need to examine a form object to recall further details on this.

    Try your break point in one these I have mentioned, and follow the code to see why you never reach your modified method?  

    Hope this helps ;)

  • Community Member Profile Picture
    on at

    Thanks dynamic_jay. Considering the form is so simple, I just enabled the Skip property on the fields that are informational only and removed the setfocus() calls. The form now works the way I want it when scanning values using a barcode scanner keyboard wedge.

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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans