Script include sysparm

Indira8
Kilo Sage

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 

9 REPLIES 9

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.

Hi  @Hitoshi Ozawa  I have already created a question :

https://community.servicenow.com/community?id=community_question&sys_id=5201e449dbc54d14b3c099ead3961925

but no response so asked for help here.

 

Thank you 

Allen Andreas
Administrator
Administrator

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!

Hi @Allen A  Thank you for your help. I actually have a requirement where I am facing difficulty with code. We have a custom table for group data and to modify that data we have a catalog item. We need to check if a logged in user is either a deputy(list of users ) or an escalation contact based on a group id (sys I'd) and then show certain variables on the field. Could you please help with how to search based on current user sys I'd. Thank you!

lcbell
Tera Expert

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();