Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Using Tab-Key to move to next form field undoes onChange?

(0) ShareShare
ReportReport
Posted on by 33
Hello everyone,

Please be so kind as to read my full post before responding.
Thank you for your consideration.

With a colleague of mine I recently stumbled upon a very strange behaviour with one simple Javacript form customization.
In a custom form for work orders (msyn_workorder), there's a custom field to store work duration in 8-hour units (kk_duration) (that's the unit our technical staff offers services in).
There is a small JavaScript customization in place to calculate minutes from that field and store it in the the out-of-the-box-field (msdyn_primaryincidentestimatedduration), which then also shows the duration in a more readable format, see screenshot.
Simple code:
 
function onChange_kk_duration(eventContext) {
    const formContext = eventContext.getFormContext();
    var duration = formContext.getAttribute('kk_duration')?.getValue();
    if (duration && duration > 0) {
        formContext.getAttribute('msdyn_primaryincidentestimatedduration')?.setValue(Math.round(duration * 480));
    }
}

This basically works with one small caveat:
My colleague likes to switch to the next form field using the /Tab/-Key.
When he uses that after filling in the kk_duration Field and triggering onChange, msdyn_primaryincidentestimatedduration seems to reset to the previous value.
He uses Chrome as his browser, I use Firefox and we can both reproduce this strange behaviour consistently.
When using the mouse to click away or using enter to confirm the input and stay in kk_duration, there's no problem.
It seems to only occur when using tab to navigate.

Example: fill first field, tab onChange triggers, tab value resets
////

Any ideas on what makes /Tab/ cause this reset?

Thanks,
    Sa.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Adis Profile Picture

Adis 136 Super User 2025 Season 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 81

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 77 Super User 2025 Season 1

Product updates

Dynamics 365 release plans