showFieldMsg - scrollForm

krishnasundar
Giga Contributor

Hello,

I would like to share the issue/solution we faced in form focus.

Issue:

While creating an incident, the form does not focusing the first editable field in the form. Instead it is navigating to our custom field which is at the bottom of one of the form sections.

Analysis:

ServiceNow Wiki URL: Display Field Messages - ServiceNow Wiki

When a field message is displayed on a form on load, the form will scroll to ensure that the field message is visible, ensuring that users will not miss a field message because it was off the screen.

A global property (glide.ui.scroll_to_message_field) is now available that controls automatic message scrolling when the form field is offscreen (scrolls the form to the control or field).

Solution:

As wiki says, we found an on-load client script which is populating the error info message to our custom field. Since the change of the global property (glide.ui.scroll_to_message_field) may affect globally, we have just added the 4th parameter as "false" in g_form.showFieldMsg() method like below.

g_form.showFieldMsg('u_custom_field_name','Whatever message you wants to display','error', false);

Since the 4th parameter is optional, most of us left that as it is. Set this to false to prevent scrolling to the field message offscreen.

Thanks,

Krishna

4 REPLIES 4

Alex Ward
Kilo Guru

Very useful thank you

rohan raj2
Tera Contributor

thanks krishna!

poojitha bn
Giga Expert

Great thanks 🙂

Anirban Roy
Mega Guru

Thanks for sharing...