Where is the phone_number field type?

geek1
Kilo Contributor

All,

I was recently tasked with "make sure our phone numbers from the service catalog that users type in follow this criteria". So.. I did some research and found out that's done via a validation script. I wrote a JS that works perfectly for what we're needing and I had it attached to the "phone_number" field. I thought this was strange as I didn't recall seeing this as an option when building a catalog form.

Lo and behold, it's not an available choice! When I go to Variable>Type it's not an option. When I right click Type and go to Dictionary I can see phone_number but it's it isn't set up.

Anyone know how to get phone_number to show up as an option for variable type so I can use a validation script on it?

3 REPLIES 3

CapaJC
ServiceNow Employee
ServiceNow Employee

Validation Scripts work for fields, since they're tied to field types. Variables are different, and to my knowledge don't have a similar concept.

You may need to use a Catalog Client Script to do the validation on change or submit. Unfortunately, I think you'll need one for each phone number variable you use, since there's not a way to tie a single Catalog Client Script to multiple variables.


geek1
Kilo Contributor

Why is there a phone_number options for the validation script if it can't be used? Is there now way to create a phone_number field that's just a textline that then references this validation?

I have no problems going through and creating an onchange JS for each individual field but I thought that's what the validation script phone_number option was set up for already.


CapaJC
ServiceNow Employee
ServiceNow Employee

You can create a phone_number field in a table, since it's a valid field type, but it's not one of the options you'll see when personalizing a form/list and creating a field that way. Probably because that field type isn't used very often, I'm not sure. There are upwards of 75 field types, last time I checked, but not all are displayed in that dropdown when creating a field.

But you can create a String field, then edit the new Dictionary entry for that field and change the type from "string" to "phone_number" (can switch between those types since their underlying database column type is the same). Then your validation script will work for that phone_number field.

It just won't work on Service Catalog variables, for the reason in my last post.