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.
Service Portal - No validators exist for IP, Email, Duration and URL type variables. - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • Service Portal - No validators exist for IP, Email, Duration and URL type variables.
KB0661825

Service Portal - No validators exist for IP, Email, Duration and URL type variables.


3962 Views Last updated : Jul 8, 2025 public Copy Permalink
KB Summary by Now Assist

Description

Service Portal currently does not validate the following variable types: IP, Email, Duration, and URL. 

 

Steps to Reproduce

  1. Create a catalog item with the following types of variables:

    • IP
    • Address
    • Duration
    • Email
    • URL

    For more information, see the product documentation topic Create a service catalog variable.

  2. Launch the Service Portal instance and navigate to the newly created catalog item.

  3. Try to give incorrect values to the newly created types of variables and observe the result.

    No validators are provided for these variable types in Service Portal, so there is no indication for the user that the entered value is incorrect.

 

 

Workaround

Use onChange catalog client scripts to validate the input. You can use either a simple script when only a few variables need to be validated or a more robust and centralized approach for a larger installation.

Small Installation

The following example demonstrates this approach for an Email variable. The script uses a regular expression to validate the email address, and displays a notification if the user inputs an invalid value. This sample script can be applied to the other variable types by using different regular expressions that are applicable to that type.

 

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading || newValue == '') return;
  
  function validateEmail ( email ) {
    
    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test( email.toLowerCase() );
  }
  
  if ( !window ) { // Only run in Service Portal
    
    var variableName = 'valid_email'; // Update this to match your variable's name
    
    g_form.hideFieldMsg( variableName, 'true' ); // Hide any existing field messages
  
    if ( !(validateEmail( newValue )) ) {
    
      g_form.showFieldMsg( variableName, 'Invalid email address: '+newValue, 'error', false );
      g_form.setValue( variableName, '' ); // Clear out the invalid value
    }
  }
}

 

Larger Installation

Larger implementations necessitate a more robust and centralized approach. You can define the validation function in a script include and abstract it to handle all four of the affected variable types, as shown in the following example.

  

function validateVariable ( val, type ) {

  var regExs = {

    email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
       ip: /.../, 
      dur: /.../,
      url: /.../
  };

  return regExs[type].test( val.toLowerCase() );
}

 

Client scripts can be simplified to call the same function via GlideAjax. If you need assistance with creating the regular expressions for the other variable types, consider searching online for a regex generator site to make them for you.

 

 


Related Problem: PRB957575

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.