- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 02:49 AM
Hi
I have a requirement :
I need to Auto create incident task when the Major incident feild is Checked and incident state is changed to resolved.
For this i have created one business rule
conditions : AFTER - Update
Major incident is true
state changes to resolved
Script:
var incTask = new GlideRecord('incident_task');
incTask.initialize();
incTask.short_description = current.short_description;
incTask.incident = current.sys_id;
incTask.insert();
Here the issue i am facing, If the incident is moved to resolved state incident task is created, But if the same incident state is back to inprogress and after that again it moves resolved state it creating another incident task for same incident.
As per my requirement, I need incident task first time state moves to resolved
Please help me on this
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 03:00 AM
Hello
In this case, you can have one condition to check whether "Incident_task" is already created or not for specific Incident only then create new incident_task, else it should not create new incident_task.
Write the below script in BR as you mentioned
var grIT = new GlideRecord('incident_task');
grIT.addEncodedQuery("incident="+current.sys_id);
grIT.query();
if(!grIT.next()) { //If there is no Incident task created on Incident then go inside If
//Execute your Insertion code as you mentioned..
}
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 02:54 AM
Hi,
Taking a step back, I want to understand what good a task do when incident is already marked resolved?
Who will look at this task and what will happen to it? how will it get closed?
When will incident be marked as closed?
Can you explain what you are trying to do?
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 03:00 AM
Hello
In this case, you can have one condition to check whether "Incident_task" is already created or not for specific Incident only then create new incident_task, else it should not create new incident_task.
Write the below script in BR as you mentioned
var grIT = new GlideRecord('incident_task');
grIT.addEncodedQuery("incident="+current.sys_id);
grIT.query();
if(!grIT.next()) { //If there is no Incident task created on Incident then go inside If
//Execute your Insertion code as you mentioned..
}
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:30 AM
Hi
It is working as expected.
Thankyou.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:39 AM
I am glad it resolved the issue 🙂
Regards
Sulabh Garg