how to create SLA has breached by script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-31-2022 10:44 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-31-2022 10:56 PM
Have you tried to check Default SLA workflow ? There you have activity to notify after breach.
As far as your code is concerned. Assuming that you are running the workflow on sn_customerservice_task table modified script below
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('task_sla');
gr.addQuery('task', current.sys_id); //Giving only sys_id will not work depending on which table wf is running use the sys_id
gr.addQuery('has_breached', true);
gr.query();
if (gr.next()){
if (gr.sla.type == 'sn_customerservice_task') {
return 'yes';
}
return 'no';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-31-2022 10:58 PM
i am doing the workflow in interaction table. but i need to do the query from case table , so how to do that in script guide me script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-31-2022 11:19 PM
answer = ifScript();
var acc =new GlideRecord('sn_customerservice_case');
var gr = new GlideRecord('task_sla');
gr.addQuery('task', acc.sys_id);
gr.addQuery('has_breached', true);
gr.query();
function ifScript() {
if (gr.sla.type == 'sn_customerservice_task') {
return 'yes';
}
return 'no';
}
is this correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-31-2022 11:50 PM
Why are you running this query in the same workflow?
Just run it on the task_sla table (or even in the existing sla workflow). Trigger an event and send the email.
If my answer helped you in any way, please then mark it as helpful.
Mark
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark