How to get an integer field on a catalog form

e_wilber
Tera Guru

When I am creating variables for a record producer on the service catalog, I don't see the integer field that is mentioned Introduction to Fields - ServiceNow Wiki

How do I set my fields to an integer?

4 REPLIES 4

Abhinay Erra
Giga Sage

We do not have integer fields OOB, but you can create a single line text and write a client script to validate the data entered is a integer.


ankitbadola
Giga Expert

These Field are for the Table creation ,,,in the link that you have mentioned.....use this for more detailed information...Record Producer - ServiceNow Wiki


find_real_file.png



PS: Hit like, Helpful or Correct depending on the impact of the response


Chuck Tomasi
Tera Patron

As an alternative, some have used a choice list (e.g. to indicate a quantity). It prevents people from saying "I need 1000 computers tomorrow!" when the choices are 1-4. 🙂


Vladi1
Kilo Guru

Hi,


I had to create numeric field that would accept 2 digits only.


I set "variable attribute" to 2 - max_length=2


There are several responses on community or online how to define numeric/integer field, so I was able to modify one of the scripts:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue == '') {


  return;


  }


  var regexp = /^([0-9]+[0-9])/;


  if(!regexp.test(newValue)) {


  alert('Please enter a 2 digit number');


  g_form.setValue('variable name','');


  }


}



sources


INteger only field


Integer Field Formatting


Creating Regular Expressions in JavaScript