- 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:58 AM
Hi @AshishKM & @Runjay Patel
I respect your technical expertise.
But the requirement is to cancel case SLA when the HR Task gets cancelled, and in SLA we don't have the option/field to call the HR TASK table and that is the reason I think BR is required.
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 03:32 AM
@SiddharthG55401 @Community Alums @Dr Atul G- LNG - Thanks for reviewing our reply.
@Runjay Patel We are on same page 😎
Some points here :
SLA is running on HR Core Case [ sn_hr_core_case ] ( as given in screenshot )
If HR Task has SLA configure ( custom ), then no reason to cancel the SLA on HR Case recod.
OOTB, the SLA configured on HR Case [ sn_hr_core_table ] and applying SLA on HR Task also ( thank to that team 😀 )
The code share by @Community Alums , where the BR running on HR Task table and expecting to cancle the SLA on HR Task record will work if SLA configued on HR Task table. Now the point is, if the SLA are configured on HR Task table, why we need BR, use the "When to cancel" condition.
So @SiddharthG55401 - please confirm about configured SLA on which table.
- If its on HR Task -> u can use the when to cancel
- If its on HR Case - > dont use that cancel logic, becuase there might be some case where more than one HR Task, and HR Case is still valid.
Waiting for your reply here. 😎😀
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 03:33 AM
learning from both you Guru's.
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 04:07 AM
Thank you 😎We all are leaning from each other. Its team work here.
and thanks for all those who are asking question, and we learing/exploring the answers.
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:51 AM
Hi @SiddharthG55401 ,
You can achieve it via configuration in SLA no need of writing any script. Just select when to cancel= cancel condition are met and add the condition like state =cancelled.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------