Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 09:59 AM
How to find incidents attached to the problem records?
Scenario: we have 10 problem records , out of 4 problem records have incidents ,how to achieve this ?
Please help me on this.
Thanks
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 08:52 PM
Hi @Ramanjaneyuv check below script
var grProblem = new GlideRecord('problem');
grProblem.query();
while (grProblem.next()) {
var problemNumber = grProblem.getValue('number');
var grIncident = new GlideRecord('incident');
grIncident.addQuery('problem_id', grProblem.sys_id);
grIncident.query();
gs.print('Problem Record: ' + problemNumber);
if (grIncident.hasNext()) {
gs.print('Related Incidents:');
while (grIncident.next()) {
gs.print(' - Incident Number: ' + grIncident.getValue('number'));
}
} else {
gs.print('No related incidents.');
}
}
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 09:05 PM
Hi @Ramanjaneyuv if my answer helps you please accept solution and mark helpful