Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2024 04:17 AM
what is the background script for print the active incidents associated to the closed problem and close those incidents?
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 09:41 AM
Hi @SANNAPUREDDYV Try below code and modify accordingly
var problemGR = new GlideRecord('problem');
problemGR.addQuery('state', '6');
problemGR.query();
while (problemGR.next()) {
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('problem', problemGR.sys_id);
incidentGR.addQuery('state', '!=', '7');
incidentGR.query();
while (incidentGR.next()) {
gs.info('Closing Incident: ' + incidentGR.number + ' associated with Problem: ' + problemGR.number);
// Close the incident
incidentGR.state = '7';
incidentGR.update();
}
}
gs.info('Script completed successfully.');
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 09:41 AM
Hi @SANNAPUREDDYV Try below code and modify accordingly
var problemGR = new GlideRecord('problem');
problemGR.addQuery('state', '6');
problemGR.query();
while (problemGR.next()) {
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('problem', problemGR.sys_id);
incidentGR.addQuery('state', '!=', '7');
incidentGR.query();
while (incidentGR.next()) {
gs.info('Closing Incident: ' + incidentGR.number + ' associated with Problem: ' + problemGR.number);
// Close the incident
incidentGR.state = '7';
incidentGR.update();
}
}
gs.info('Script completed successfully.');