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.
The function g_form.hasField() does not work for variables under Variable Editor - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • The function g_form.hasField() does not work for variables under Variable Editor
KB0696941

The function g_form.hasField() does not work for variables under Variable Editor


4846 Views Last updated : Mar 24, 2023 public Copy Permalink
KB Summary by Now Assist

Description

When using the function g_form.hasField on any variables which are part of a Variable Editor in a Requested Item or any Task record form, the function does not return any correct value, but always 'false'.

 

Steps to Reproduce

 

  1. Open the "Paper and Supplies" Catalog item
    /nav_to.do?uri=sc_cat_item.do?sys_id=10a2f5dfc6112276018db58138c7a1e0
  2. Go to Catalog Client Scripts > Create New
    Name = Test hasField Functionality
    Type = onLoad
    UI Type = All
    Check box true for "Applied on requested item" and "Applies on Catalog Task"
    Script =
function onLoad() {
//Type appropriate comment here, and begin script below
alert("Value of Pens:- " + g_form.getValue("pens"));
alert("Variable 'Pens' exists on Form:- " + g_form.hasField("pens"));
}
  1. Click on Try it.
  2. Fill up all fields and Submit.
  3. Open Requested Item (RITM) record. Notice the second alert box displays false as the variable requested_by value is inside the Variable Editor.

 

Workaround

After carefully considering the severity and frequency of the issue, and the cost and risk of attempting a fix, it has been decided to not address this issue in any current or near future releases. We do not make this decision lightly, and we apologize for any inconvenience.

 


Related Problem: PRB1302040

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.