- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 01:45 AM
Hi All
Whenever an incident task is removed from on hold then the incident also should be removed from on hold only If no other incident tasks under that incident is already on hold awaiting caller.
Can anyone help ?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:14 AM
Hi @shash gauti
You have to create a After Update BR on table incident_task with condition state changes from on-hold
var incTask = new GlideRecord('incident_task');
incTask.addQuery('incident',current.incident);
incTask.addQuery('state',,'on-hold');//if on-hold value is different add the correct value
incTask.query();
if(!incTask.next()){
var incident = new GlideRecord('incident');
incident.get(current.incident);
incident.state = 'add your value';
incident.update();
}
Regards,
Piyush Sain

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:25 AM
Try below.
Create after BR on incident task table.
(function executeRule(current, previous /*null when async*/) {
var count=0;
var tasks = new GlideRecord('incident_task');
tasks.addQuery('incident',current.incident);
tasks.query();
var taskcount = tasks.getRowCount();
while(tasks.next())
{
if(tasks.state != 'onhold')//change as required
{
count++;
}
}
if(count == taskcount)
{
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',current.incident);
inc.query();
if(inc.next())
{
inc.state = 'add state value';
inc.update();
}
}
})(current, previous);
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 04:00 AM
Hi @shash gauti
You can give a try with Flow Designer.
Look Up records with condition.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:05 AM
Hi,
Please try below approach:
BR - RemoveIncidentFromOnHold
Condition:
Active is true
incident.state is 'On Hold
incident_task.state is not 'On Hold'
Script:
(function executeRule(current, previous /*null when async*/) {
var incidentGR = new GlideRecord('incident');
if (incidentGR.get(current.incident)) {
var onHoldTasks = new GlideRecord('incident_task');
onHoldTasks.addQuery('incident', incidentGR.sys_id);
onHoldTasks.addQuery('state', 'On Hold');
onHoldTasks.query();
// If no other incident tasks are on hold, update the incident state
if (!onHoldTasks.hasNext()) {
incidentGR.state = 'In Progress'; // Set the desired state when not on hold
incidentGR.update();
}
}
})(current, previous);
Regards,
Shoheb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:14 AM
Hi @shash gauti
You have to create a After Update BR on table incident_task with condition state changes from on-hold
var incTask = new GlideRecord('incident_task');
incTask.addQuery('incident',current.incident);
incTask.addQuery('state',,'on-hold');//if on-hold value is different add the correct value
incTask.query();
if(!incTask.next()){
var incident = new GlideRecord('incident');
incident.get(current.incident);
incident.state = 'add your value';
incident.update();
}
Regards,
Piyush Sain

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:25 AM
Try below.
Create after BR on incident task table.
(function executeRule(current, previous /*null when async*/) {
var count=0;
var tasks = new GlideRecord('incident_task');
tasks.addQuery('incident',current.incident);
tasks.query();
var taskcount = tasks.getRowCount();
while(tasks.next())
{
if(tasks.state != 'onhold')//change as required
{
count++;
}
}
if(count == taskcount)
{
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',current.incident);
inc.query();
if(inc.next())
{
inc.state = 'add state value';
inc.update();
}
}
})(current, previous);
Regards,
Musab