Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Glide record

soniya patil
Tera Contributor

How to print 5 active incident tickets

6 REPLIES 6

Harish Bainsla
Kilo Patron
Kilo Patron
var gr = new GlideRecord('incident');
gr.addQuery('active','true');
gr.orderByDesc('sys_created_on');
gr.setLimit(5);
gr.query();
while(gr.next())
{
gs.log("The active records" + gr.number);}
HarishBainsla_0-1703141456086.png

 

swathisarang98
Giga Sage

Hi @soniya patil ,

 

Please find the below code to print 5 active records.

 

 

 

var gr=GlideRecord('incident');//Gliding to incident Table
gr.addQuery('active',true);//querying for active records
gr.setLimit(5);//Setting the output limit to 5
gr.query();//Querying
while(gr.next())
{
    gs.print('The active incident number is ' + gr.number);// print the active incident
}

 

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang