Can we make a single line text catalog variable to be entered in a specific format?

S_53
Kilo Guru

Hey snow folks,

I have a single line text catalog variable called 'Alert Frequency' and I want to force the users to enter a specific format in it.

I made the max length of it to 12 and I want it in the format of 30,15,7,5,1 (something like this) with only numbers and commas.

I am able to restrict it to enter only numbers and commas but user can enter something like 123123 which doesn't make sense. 

I need something like number,number,number..... as shown below

 

find_real_file.png

 

Any thoughts?

 

Thanks in advance! 

1 ACCEPTED SOLUTION

Abhishek Pidwa
Kilo Guru

Hello ,

 

So after digging a bit and modifying some of the regex patterns, I found a solution for you. basically you can copy paste this entire code in your catalog client script for that catalog variable:

 

This will check various edge cases like no alphabets, no comma at the end , no comma in the beginning, only numbers etc etc.

 

find_real_file.png

 

Happy coding. Make sure that you change the variable names accordingly and you are good to go !

 

find_real_file.png

 

find_real_file.png

 

find_real_file.png

find_real_file.png

find_real_file.png

 

Please mark this answer as correct if this helps to solve your problem.

 

Thanks

View solution in original post

5 REPLIES 5

SatheeshKumar
Kilo Sage
Use regex to get this, In madrid we have a special feautre to help this, check the below link for more info https://community.servicenow.com/community?id=community_article&sys_id=e334bc4cdbe0bf48fff8a345ca9619c5 -Satheesh