How get all incidents as a true

MuruguntlaM
Giga Contributor

var fun=new GlideRecord('incident);

fun.ActiveQuery();

fun.query();

while(fun.next()){

gs.print(fun.number);

}

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @MuruguntlaM 

 

You want to print the Active incident? You can use the list view as well and just select active = True.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Rishi_11
Kilo Sage

Hi @MuruguntlaM ,

 

There are some typos in your script. Try the updated script below.

var fun=new GlideRecord('incident');
fun.addActiveQuery();
fun.query();
while(fun.next()){
gs.print(fun.number);
}

Please mark this response as correct or helpful if it assisted you with your question.

Thanks,

Rishi.

swapnali ombale
Kilo Sage

Hi @MuruguntlaM 

 

Below are the code to get active incidents

var gr = new GlideRecord('incident');   // Create a new GlideRecord object for the 'incident' table
gr.addActiveQuery();                    // Add a query to return only active incidents
gr.query();                             // Execute the query

while (gr.next()) {                     // Loop through each record returned by the query
    gs.print('Incident Number: ' + gr.getValue('number'));    // Print the Incident Number
     
}

 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway.