How do I restrict length of characters of variables in multi row variable set ?

Suresh karedla
Tera Contributor

How do I restrict length of characters of variables in multi row variable set and only alpha-numeric characters should be allowed

I have create a multi row variable set for catalog item form.

find_real_file.png

 

So that I can add multiple customer codes just by clicking on add.

How to validate to allow only alpha - numeric characters and miimum and maximum characters 6 or 7 (example: test123)

if i use client script getting out as below:

find_real_file.png

 

Please help me on this.

Thanks,

Suresh

 
Topics: Service Catalog
Version: ROME
1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi @Suresh karedla,

You have to use the max_length=7 as variable attributes for Customer Codes[customer_code] variable in MRVS * annotations as

Enter Customer Codes up-to 5 characters only

find_real_file.png

 

For Regular expression, you to add new regex in Service Catalog ---> Catalog Variables ---> Variable Validation Regex with your message.

Regex - ^[a-zA-Z0-9]*$

 

find_real_file.png

Result -

find_real_file.png

 

Thanks,

Sagar Pagar

The world works with ServiceNow

View solution in original post

5 REPLIES 5

Aman Kumar S
Kilo Patron

Hey,

Have you explored on Variable Validation Regex?

It is a no code way for validating catalog variables using Regular expression.

Your regular expression would be something like this:

/^([a-zA-Z0-9_-]){6,8}$/ where it means it can have size from 6 to 8, if you want only lower limit you can update as (6,}

Below article helps you to achieve this

Service Portal Catalog Items: Regex Field Validation [Madrid]

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

Thank you Aman kumar for your help.

Sagar Pagar
Tera Patron

Hi @Suresh karedla,

You have to use the max_length=7 as variable attributes for Customer Codes[customer_code] variable in MRVS * annotations as

Enter Customer Codes up-to 5 characters only

find_real_file.png

 

For Regular expression, you to add new regex in Service Catalog ---> Catalog Variables ---> Variable Validation Regex with your message.

Regex - ^[a-zA-Z0-9]*$

 

find_real_file.png

Result -

find_real_file.png

 

Thanks,

Sagar Pagar

The world works with ServiceNow

For non -alphanumeric, it will show error message as -

find_real_file.png

Thanks,
Sagar Pagar

The world works with ServiceNow