How get all incidents as a true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2025 07:04 AM
var fun=new GlideRecord('incident);
fun.ActiveQuery();
fun.query();
while(fun.next()){
gs.print(fun.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2025 09:59 AM
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2025 10:15 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2025 12:17 PM
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.