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.');