how to create SLA has breached by script

devservicenow k
Tera Contributor

MY requirement is in SLA using Workflow.

i am creating an sn_customerservice_task

. when ever sn_customerservice_task is created SLA should run for 24 hours.

if the SLA has breached , the  notification should be sent.

i have created an code to check the task is breached , but it is not working

answer = ifScript();
var gr = new GlideRecord('task_sla');
gr.addQuery('task', sys_id);
gr.addQuery('has_breached', true);
gr.query();
   function ifScript() {
    if (gr.sla.type == 'sn_customerservice_task') {
       return 'yes';
      }
      return 'no';
         }

send me the updated script

11 REPLIES 11

Few things needs to be clear.

 

If workflow is interaction table. Is there any field in interaction table which references to case or case task. We need at-least 1 field in interaction table to refer to case or case task to be able to do this.

Best and easiest thing to do is to modify the workflow assigned for the SLA it will have a notification activity after SLA is breached. MOdify the workflow selected in the highlighted field of the SLA definition

find_real_file.png

I have given the interaction table in workflow , becuse im getting the value from the inbound actions and i am getting the interaction field value to copy to case tbale

But the workflow should run on task_sla table. Change the table in workflow

Below should be the script of workflow running on task_sla table

answer = ifScript();

function ifScript() {

if (task.sys_class_name == "sn_customerservice_task")

{

    if (current.has_breached.toString() == 'true'){

        return 'yes';
      }
      return 'no';
         }

}

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Would you mind closing your earlier questions as answered if you were able to resolve it?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader