Is there a limit to the length of a number in an integer field?

myron_mccarthy
Kilo Explorer

It appears when I enter a number larger then 10 digits into an integer field, the field is populated with 2147483647 (which interestingly enough is only one of 4 double mersenne primes). Is this a limitation of that field type?

1 ACCEPTED SOLUTION

domaners
Kilo Guru

This appears to be a limitation of the MySQL database that Service Now is hosted on, I don't think there's much you can do about this. The following wiki article demonstrates that Integer fields in Service Now are saved Integer data type (no surprises there!).



http://wiki.servicenow.com/index.php?title=Introduction_to_Fields#Database_Field_Types



Looking at the online MySQL documentation, it is shown that the max value that can be stored in a signed Integer variable is 2147483647, as you have witnessed.



MySQL :: MySQL 5.1 Reference Manual :: 11.2.1 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, ...



It may be worth raising a ticket on Hi to see if one of their DBA's can change the data type on this field to unsigned Integer (which would mean no negative values), or BIGINT. This may require a new field to be set up though, as I'm not sure if MySQL will be able to convert datatypes in this way.


View solution in original post

9 REPLIES 9

Thanks,


That explains it. I have replaced the field with a string field. Do you know how to create a validation script that will limit the input to numbers?


var re = /^\d+$/;


var isInteger = re.test(newValue);


Vladi
Tera Contributor

"Long" is what you are looking for.


Tim Woodruff
Mega Guru

There are two types of fields that can probably evade this limitation. One is "longint", and the other is "int" (Integer string)

The second is just an int stored as a string, I'm not certain if you can query/sort/whatev the exact same way as an actual integer. But I'm pretty sure longint is just an unsigned int or something. 

"longint" should be able to do what you're looking for. 

Pandimeena R
Mega Contributor

If we enter max length is 15 for a particular field then we can able to enter 14 digits only. How to Fix and enter the 15 digits accurately.

Could you anyone clarify this?