How to auto close Incident if incident tasks are closed using Flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2023 11:39 PM
Hi,
I have a requirement stated below:
Once P2 incident is created approval should be triggered to Caller's manager.
If manager approves then approval should go to the assigned group and if rejected Incident state should be cancelled.
If assigned group approves then an incident task should be created, if rejected Incident state should be cancelled.
If the Incident task is closed completed/closed skipped/closed incompleted then Incident state should be closed.
OR
If the Incident task is pending/work in progress/open then Incident state should be in progress.
I have configured till the task creation but for auto closure of incident depending upon incident task is pending. Can anyone please help on the same.
Thanks and regards,
Ridhima
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:10 AM
Hi,
You can set incident state to in progress when incident task gets created. Rest this line"If the Incident task is closed completed/closed skipped/closed incompleted then Incident state should be closed." will take care of the other requirement.
If you want to validate then you can write a Before BR and that will check the incident task state,if it is as per the requirement then proceed otherwise abort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 01:13 AM
Hi,
Requirement is to do using flow designer.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 02:41 AM
Hi, pls use the below script as an example for your reference. Use flow and action recreate the same in flows.
(function executeRule(current, previous /*null when async*/ ) {
var count = 1;
var tasks = new GlideRecord('incident_task');
tasks.addQuery('incident', current.incident);
tasks.query();
var taskcount = tasks.getRowCount();
gs.addInfoMessage(taskcount);
while (tasks.next()) {
if (tasks.state == 3 || tasks.state == 4 || tasks.state == 7) //change as required
{
count++;
}
}
gs.addInfoMessage(count);
if (count == taskcount) {
var inc = new GlideRecord('incident');
inc.addQuery('sys_id', current.incident);
inc.query();
if (inc.next()) {
inc.state = 6;
inc.close_code = 'Solved (Permanently)';
inc.close_notes = 'Incident closed on closure of all incident task';
inc.work_notes = ' Incident closed on closure of all incident task';
inc.update();
}
}
})(current, previous);
Suresh.