what is the purpose of gs.include('validators')

sohan_snow
Tera Contributor

Hi All,

I see gs.include('validators') being used in inbound email actions, also could see that it relates to a script include- validators that has three functions isnumeric, isInteger and containsOnlyChars defined it.

But unable to figure out what it is for and what exactly is it doing. Any suggestion please

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

Allows you to validate the data coming in when you script is looking for input. Things like isNumeric, or isInteger or containsOnlyChars


Example is on Priority check:



                                              if (email.body.priority != undefined && isNumeric(email.body.priority))



isNumeric is checked in the script includes - validators - to make sure it's a number.


View solution in original post

3 REPLIES 3

abhishekdash
ServiceNow Employee
ServiceNow Employee

Hello Sohan,



gs.include() is   used to call a script include.


In this case its calling the script include called 'validators'.



https://yourinstancename.service-now.com/nav_to.do?uri=sys_script_include.do?sys_id=2474b5890a0a0aa7...



And as per the description of the above script include it is used for 'validation scripts for validating the type of text and whatnot'.



If this reply assisted you, please consider marking it Correct, Helpful, or Like it.


This helps other customers to learn from your thread.



Thanks,


Abhishek


gs.include() is an outdated mode of calling a script include. It hasn't been required for several years. When you see it, I suspect you are looking at some very old code. Script includes are automatically loaded on demand.


Michael Fry1
Kilo Patron

Allows you to validate the data coming in when you script is looking for input. Things like isNumeric, or isInteger or containsOnlyChars


Example is on Priority check:



                                              if (email.body.priority != undefined && isNumeric(email.body.priority))



isNumeric is checked in the script includes - validators - to make sure it's a number.