Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
g_form.showFieldMsg scrollForm does not work in CMS - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • g_form.showFieldMsg scrollForm does not work in CMS
KB0551901

g_form.showFieldMsg scrollForm does not work in CMS


3160 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Description

g_form.showFieldMsg scrollForm does not work in CMS.

Steps to Reproduce

The [scrollForm] behavior documented in the 'g_form.showFieldMessage' method does not work in CMS; scrolling to the message only works in non_CMS.

  1. Log in to a Fuji instance.
    Note that glide.ui.scroll_to_message_field is true in the base system.
  2. Navigate to Service Catalog > Categories > Maintain Items.
  3. Select any active catalog item (for example, Apple iPhone 5).
  4. Add a new yes/no checkbox (test1) variable with the lowest order value so it displays at the top.
  5. Add a new Multi Line Text (comments1) variable with the highest order value so it displays at the bottom.
  6. Add the Catalog Client Scripts -> Catalog Item related list to the catalog item form by using Configure > Related List.
    • Name: setFocus
    • Applies to: A Catalog Item
    • Active: true
    • UI Type: Desktop
    • Application: Global
    • Type: onChange
    • Catalog Item: Apple iPhone 5
    • Variable name: test1
    • Applies on a Catalog Item view: true
    • Script:

      function onChange(control, oldValue, newValue, isLoading) {
      if (isLoading || newValue == '') {
      return;
      }
        g_form.showFieldMsg("comments1", "You need to populate Comments","info",true);
      }

  7. From the Catalog Item record, click the Try It button.
  8. Change yes/no checkbox (test1) variable from Yes to No.
  9. Focus and auto-scroll to message and field specified (comments1).
  10. Launch CMS and repeat steps.
    The message is displayed, but focus and auto-scroll does not occur.

Workaround

There are two options.

The first option is to display the message right underneath field (test1 in above scenario) by modifying script:

from:  

g_form.showFieldMsg("comments1", "You need to populate Comments","info",true);

to:

g_form.showFieldMsg("test1", "You need to populate Comments below","info",true);

-or-

The second option is to force the focus to the field at the bottom of the form by modifying the script to:

g_form.showFieldMsg("comments1", "You need to populate Comments","info",false);
location.href="#";
location.href="#" + g_form.getControl('comments1').id;


Related Problem: PRB648044

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.