want to change SLA status to cancel when HR task changes to canceled state in HRSD

SiddharthG55401
Tera Contributor

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.

SiddharthG55401_0-1734517557879.png

 

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @SiddharthG55401 

 

It is not directly possible on SLA table, you need to run BR

 

https://www.servicenow.com/community/itsm-forum/how-to-stop-sla-based-on-catalog-task-state-field-ch...

*************************************************************************************************************
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]

****************************************************************************************************************

View solution in original post

Community Alums
Not applicable

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.

View solution in original post

10 REPLIES 10

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]

****************************************************************************************************************

@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

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]

****************************************************************************************************************

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

Runjay Patel
Giga Sage

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.

RunjayPatel_0-1734519007126.png

 

-------------------------------------------------------------------------

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

-------------------------------------------------------------------------