- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 02:27 AM
Hi Everyone,
I want to set SLA status to cancel when a user changes the HR task to canceled state. Please let me know if this is possible.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 02:39 AM
It is not directly possible on SLA table, you need to run BR
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
12-18-2024 02:45 AM
Hi @SiddharthG55401 ,
Yes, it is possible to set the SLA status to "Canceled" when the HR task state is changed to "Canceled." This can be achieved by using a Business Rule on the sn_hr_core_task table to update the SLA status.
if (current.state == 'canceled') { // Check if the state is set to "Canceled"
var slaGr = new GlideRecord('task_sla');
slaGr.addQuery('task', current.sys_id); // Fetch SLAs linked to this task
slaGr.query();
while (slaGr.next()) {
slaGr.setValue('stage', 'canceled'); // Update SLA stage to "Canceled"
slaGr.update();
}
}
Replace 'canceled' with the exact value of the "Canceled" state in your HR task state dictionary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 02:39 AM
It is not directly possible on SLA table, you need to run BR
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
12-18-2024 02:45 AM - edited 12-18-2024 02:51 AM
Hi @SiddharthG55401 ,
Please check on the same page there is "When to cancel" option, use it and test.
As you have only one condition for start, afer cancel, the record will not be in same condition to keep the running SLA instance if when to cancel condition configured.
Or you can configure the cancel condition based on active or state field value.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 02:45 AM
Hi @SiddharthG55401 ,
Yes, it is possible to set the SLA status to "Canceled" when the HR task state is changed to "Canceled." This can be achieved by using a Business Rule on the sn_hr_core_task table to update the SLA status.
if (current.state == 'canceled') { // Check if the state is set to "Canceled"
var slaGr = new GlideRecord('task_sla');
slaGr.addQuery('task', current.sys_id); // Fetch SLAs linked to this task
slaGr.query();
while (slaGr.next()) {
slaGr.setValue('stage', 'canceled'); // Update SLA stage to "Canceled"
slaGr.update();
}
}
Replace 'canceled' with the exact value of the "Canceled" state in your HR task state dictionary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 02:53 AM
@Community Alums - this code example is good to implement, however SLA itself has such option to manage the cancel case, @SiddharthG55401
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution