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.
removeOption does not worth through client script access to variable fields on task records - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • removeOption does not worth through client script access to variable fields on task records
KB0678206

removeOption does not worth through client script access to variable fields on task records


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

Description

For forms where variables are shown, for example, sc_req_item, using removeOption in a client script to remove an option from a variable field in a client script will not work.

Note that the catalog client script has no issues with this method when running on com.glideapp.servicecatalog_cat_item_view.do.

Steps to Reproduce

  1. Go to the sc_req_item table and go to the Blackberry catalog item.

  2. Add a new variable select box named "test_var".

    For more information, see the product documentation topic Create a Service Catalog variable.

  3. Add three choices to the variable named "choice_one", "choice_two", and "choice_three".

  4. Create a new client script with the following values:

    • Type: onLoad
    • Table: sc_req_item
    • Script:
      function onLoad() {
      g_form.removeOption('variables.test_var','choice_one');
      }
  5. Submit a new Blackberry catalog.

  6. Go to the request item form.

    The test_var variable should contain only two choices but three choices are available including choice_one, which should have been removed.

    Workaround: g_sc_form.removeOption('test_var', 'choice_one');

 

Workaround

Note that only the following APIs are supported:

  • g_form.setDisplay(name, display)
  • g_form.setVisible(name, visibility)
  • g_form.setMandatory(name, mandatory)
  • g_form.setValue(name, value, display_value)
  • g_form.getValue(name)
  • g_form.setReadOnly(fieldName, boolean)

g_form.removeOption is not supported.

For more information, see the product documentation topic Client script access to variable fields on task records.

 


Related Problem: PRB626041

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.