Script include sysparm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 01:55 PM
Could someone please help me explain what is sysparm_serial in the following script:
checkAssetSerial: function() {
var sno = this.getParameter("sysparm_serial");
var gr1 = new GlideRecord('alm_hardware');
gr1.addQuery('serial_number', sno);
gr1.query();
if (gr1.next()) {
return true;
} else {
return false;
}
Thank you
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 10:47 PM
Don't see how that is related to the question in this thread about sysparm_serial.
Please create a new question if it is not related. That's the rule of these forums.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 10:58 PM
Hi
https://community.servicenow.com/community?id=community_question&sys_id=5201e449dbc54d14b3c099ead3961925
but no response so asked for help here.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 07:07 PM
Hi,
I'd recommend reviewing this GlideAjax cheat sheet to get more information on this and the bigger picture: https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 08:49 PM
Hi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 01:46 PM
The code can be improved by using better variable names and using GlideAggregate instead of GlideRecord since you don't need to return any data, but if you do use GlideRecord then add gr1.setLimit(1);
then replace all the if...else lines with return gr1.hasNext();
var serial_number = this.getParameter("sysparm_serial");
if(!serial_number) return;//always validate the data! returns undefined which is falsey, don't really need a boolean
var gr1 = new GlideAggregate('alm_hardware');
gr1.addQuery('serial_number', serial_number);
gr1.setLimit(1);
gr1.query();
return gr1.hasNext();