- 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 05:26 AM
what did you start with?
where are you stuck?
Unless you start and debug you won't learn.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader