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

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]

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

AshishKM
Kilo Patron
Kilo Patron

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.

 

 

AshishKM_0-1734518656380.png

 

Or you can configure the cancel condition based on active or state field value.

 

AshishKM_1-1734519005847.png

 

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

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.

@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