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.
onChange client Scripts are executing twice on Date Variables when there value is cleared or changed as part of the script in Service Portal - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • onChange client Scripts are executing twice on Date Variables when there value is cleared or changed as part of the script in Service Portal
KB0696703

onChange client Scripts are executing twice on Date Variables when there value is cleared or changed as part of the script in Service Portal


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

Description

onChange client Scripts are executing twice on Date Variables when their value is cleared or changed as part of the script in Service Portal

Steps to Reproduce

  1. Log in to an OOTB London instance (verified in demonightlylondon)
  2. Open the record producer 'Create incident'
    • https://<instance-name>.service-now.com/nav_to.do?uri=sc_cat_item_producer.do?sys_id=3f1dd0320a0a0b99000a53f7604a2ef9
  3. Create a Date variable, say 'start_date'
  4. Create an onChange catalog client script on the above Date variable as follows:
    • Name: test alert
    • UI type: all
    • Type: onChange
    • Variable name: start_date
    • Script:
      function onChange(control, oldValue, newValue, isLoading) {
      if (isLoading || newValue == '') {
      return;
      }
      //Type appropriate comment here, and begin script below
      if(newValue) {
      alert("Called-oldvalue:"+oldValue+";newvalue="+newValue);
      g_form.clearValue('start_date');
      }
      }
  5. Open the Record Producer from the Service Portal
    https://<instance-name>.service-now.com/sp?id=sc_cat_item&sys_id=3f1dd0320a0a0b99000a53f7604a2ef9
  6. Select a date for the above Date variable

Expected behavior:
When you change the value of Date Variable 'start_date', the alert should show once.

Actual behavior:
When you change the value of Date Variable 'start_date', the alert shows twice.

Note: The issue is seen only on Date variables. If we repeat the same steps for a Single Line Text variable, the alert is shown only once.

Workaround

This issue is under review. To receive notifications when more information is available, subscribe to this Known Error article by clicking the Subscribe button at the top right of the article. If you are able to upgrade, review the Fixed In field to determine whether any versions have a permanent fix.


Related Problem: PRB1301582

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.