How do you cancel a completed SLA when state changes from Resolved back to Open

Sarah Barnes
Tera Contributor
My customer is trying to write reports based on SLAs, however they only want to show the SLA based on the Last SLA completed, if that makes sense. Here is the scenario, both the Resolution and Response SLA kick off immediately - the Response SLA complets when the Case is Assigned to a person. The Resolution coninues to resolved state where it completes, however if the Case is reopened then SLA Starts again and now we have 2 Resolution SLAs, when we want to just report on the one SLA, as in the one that is now in Progress and will eventually complete. I looked at using the Cancel Start conditions as I wanted to use if the state changes from resolution to Open, however there isn't a change from or to - so I am not sure how we either cancel a completed SLA (the resolution SLA before Reolved) or how we can ensure that we only report on the last Resolution SLA to be completed (which is the one created when it was reopened) If anyone has any great Ideas, I would really welcome the advice.
4 REPLIES 4

AndersBGS
Tera Patron
Tera Patron

Hi @Sarah Barnes ,

 

You can't cancel a completed SLA. You instead need to look at your conditions, so the SLA fist complete when the incident is closed and can't be reopened again. it could be that you should set SLA 1 in a pause state when resolved and move it to completed when incident is closed.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi @Sarah Barnes 

 

If my answer has helped with your question, please mark my answer as accepted solution.

 

best regards

Anders

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Sarah Barnes
Tera Contributor

Thanks Anders, I had already realised that it won't cancel on the complete, so we have created a flow with a field so we can report on the most recently created SLA - which was the reason for my question.

 

Much appreciated

Rahul Kumar17
Tera Guru

Hi,

 

var taskSLAs = new GlideRecord('task_sla');
taskSLAs.addQuery('task', 'TASK_SYS_ID'); // replace TASK_SYS_ID with the sys_id of the task you want to query
taskSLAs.query();

var lastCompletedSLA = null;
while (taskSLAs.next()) {
  var slaHistory = new GlideRecord('task_sla_history');
  slaHistory.addQuery('task_sla', taskSLAs.sys_id);
  slaHistory.orderByDesc('end_time');
  slaHistory.setLimit(1);
  slaHistory.query();
  
  if (slaHistory.next() && slaHistory.getValue('breached') == false) {
    lastCompletedSLA = slaHistory;
    break;
  }
}

if (lastCompletedSLA != null) {
  // use lastCompletedSLA to report on the SLA
}

 

Thanks,

Rahul Kumar

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar