Write a script to display inactive problems with p2 incidents.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 07:41 PM
Script
12 REPLIES 12
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 09:43 PM
update as this
var arr = [];
var gr = new GlideRecord('problem');
gr.addQuery("active", false);
gr.addQuery('state',4);
gr.query();
while(gr.next()){
var r = new GlideRecord('incident');
r.addQuery("problem_id", gr.sys_id);
r.addQuery('priority',2);
r.query();
while(r.next()){
arr.push(gr.number.toString());
}
}
gs.addInfoMessage(arr.toString());
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 12:28 AM
I've used DISPLAY business rule type.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 01:09 AM
Hi Sabbani,
You can use the following script, it will fetch out the related priority 2 incident for a certain problem.
var arr=[];
var prob=new GlideRecord('problem');
prob.addQuery('active',false)
prob.query();
while(prob.next()){
var inc=new GlideRecord('incident');
inc.addQuery('problem_id',prob.sys_id);
inc.addQuery('priority',2);
inc.query();
while(inc.next()){
arr.push(inc.sys_id+"");
}
}