How to stop the SLA from server Side code ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 07:59 PM
Hi Folks,
I have implemented a Cancel button, where I’ve written server-side code to cancel the Task (sc_task).
When the Task gets cancelled, the corresponding RITM and Request also get cancelled.
The problem is — when the Task and RITM are cancelled, the associated SLAs (task and ritm) are not stopping.
In my code, I’ve used current.setWorkflow(false) because I don’t want other Business Rules to run.
Could you please guide me on how to properly stop the SLAs using server-side code in this scenario?
Here is the code from my Cancel button:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 08:41 PM - edited 06-23-2025 08:41 PM
Hi @AbidSiddiqui,
Interesting setup. One thing that stands out immediately: why not handle this through Pause/Cancel conditions in the SLA definitions themselves?
That’s usually the cleanest way to stop SLAs when tasks or RITMs get cancelled. Instead of forcing it through code, you define a condition like state == X (for Cancelled), and the SLA engine takes care of the rest.
Also, worth noting, but if you’re setting current.setWorkflow(false), you’re likely bypassing any Flow/SLA updates tied to the state change. That might explain why the SLAs are still running.
Hope it helps you,
If you found my answer helpful or correct ✔️ in any way, please don't forget to mark it to help future readers! 👍
--
Kind regards,
Marcos Kassak
ServiceNow MVP 2024, 2025 ⭐
Solution Architect 🎯
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 08:50 PM
Hi Marcos ,
Thanks for the response ,
Yes that is correct I am setting "current.setWorkflow(false)," because i have few BR's that i don't want to run. yes its bypassing any Flow/SLA updates state change.
Sla is not getting state change update. (in SLA we already have stop condition matching with this ).
That is why i am trying to do it by server side code.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 11:36 PM
Hi Marcos,
Do you have any suggestions on how I should approach this?
I’m trying to handle it using server-side code in my UI action button.
While it successfully updates fields like stage (to completed) and end time, the SLA timeline still shows as running when I check it.
Thanks!