Uncle Rob
Kilo Patron

A little lesson on why understanding Data Types is crucial.  Consider this data....

 

Bob

42

3.14

12/12/2012

12:00:00

 

RobertFedoruk_1-1691799932995.png

 

DATA TYPES MATTER BECAUSE SORTING MATTERS

100,000

11

30,000

500

These are all sorted correctly.  So long as you forget that they're numbers for a moment.  If you want your numbers to sort like NUMBERS instead of strings then the data type must be numerical.  In ServiceNow that's usually Integer or Decimal.

 

DATA TYPES MATTER BECAUSE VALIDATION MATTERS

You just finished a critical employee onboarding form.  You need the start date.  Screw you, I'm putting YOLO.
Except if the field was a data type of Date or DateTime I couldn't input anything BUT data of that type.

RobertFedoruk_3-1691800198840.png

 

DATA TYPES MATTER BECAUSE BEHAVIOR MATTERS

RobertFedoruk_4-1691800280584.png

5+1... what is the value of newNumberNumber?   6

5+1... what is the value of newStringNumber?   51

RobertFedoruk_5-1691800358272.png

See ... + can add letters to other letters in a string.  So 5+1 = 51 if your data type is string.

If we need 5+1 = 6 we must presuppose the data is some type of number.  We need it to BEHAVE that way.

 

 

There are many many many datatypes in ServiceNow (and in Javascript that you use on ServiceNow).  I leave it to you to explore how those data types work, but at least now you know viscerally why the data type matters.

 

 

 

Comments
Juan Miguel
Tera Expert

Thanks for the quick article! 

Version history
Last update:
‎08-11-2023 05:35 PM
Updated by:
Contributors