Catalog variable of Integer - numbers only

Trish Mac
Mega Guru

I'd like to create a catalog variable that allows numbers only and this doesn't appear to be available OOB.  When I search the Community, people are using a variety of scripts for this.  Does something this common really require a script?

Thanks,

Trish

2 ACCEPTED SOLUTIONS

Hello @Trish Mac 

I'm unsure where our disconnect may be, as this is seeming to be more complex than it should be, haha.

 

With that said, what your screenshot provided originally, it did not appear to be saved because you still had the * asterisk icon showing on the "Question" tab, thus telling us it probably wasn't saved. Although, I think if you just filled in the "Question" tab mandatory fields, that may help with more showing in the "Type specifications" tab...so you may want to try to ensure you have all mandatory fields filled in.

 

In any case, unless you all are on some sort of very, very, very old version of ServiceNow...what I'm talking about has been in the system for several versions now.

 

I'll include two screenshots of the settings I just did (again) for you to verify against what you have. You should be able to see more than what your past screenshot shows within the "Type Specifications" tab. If you're still not seeing more there, I would recommend to delete the variable...and try again...or lastly, contact ServiceNow support as something is broken on your end.

 

AllenAndreas_0-1714423332018.png

 

AllenAndreas_1-1714423352734.png

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

Hi,

Glad you were able to see those fields. Out of box, they should all be there so that's a bit concerning that the form was customized that much to have those removed. I would recommend perhaps comparing your catalog item form and tabs to an out of box instance, just to help suggest to whomever if there should be any other fields added or removed from view.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

13 REPLIES 13

Allen Andreas
Administrator
Administrator

Hi,

You'd use a string variable, but then in the variable settings, select the regex for numbers.

AllenAndreas_0-1713463573781.png

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks Allen.  I don't see the option for a String variable type when creating a catalog item, unless there's an alternate method to indicate a String variable other than selecting from the Type list when selecting variables?  I see a String type when I'm in Form Design.  I've heard of using a Single Line Text variable with a script to achieve an Integer-type field and I applied the script provided but it didn't work, didn't limit entries to numbers only.

Hi,

Yes, single-line text would the be the equivalent. My apologies for that.

String is for the table fields, not variables, but they're the same thing essentially.

 

So the above is my screenshot from the variable settings and you'd pick single-line text or multi-line could work too, but that's a bit nutty, haha, and anyways, choose regex for Number.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you again.  Sorry if I'm being obtuse here - this is what I see when I choose Single Line Text.  No dropdown for Type Specifcations.  

TrishMac_0-1713464555026.png