Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Help with run script in SLA workflow

Abhijit Das7
Tera Expert

Hi Everyone,

 

I have created SLA workflow for RITM. I have created two run scripts in that workflow, :

 

1. When SLA completes 75% , the assignment group of RITM should be changed to another assignment group 

 

 

var reqItem  = current.task.request_item;

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', reqItem);
gr.query();
if(gr.next()){
	gr.setValue('assignment_group' , 'ad79161133dd16506058eae13d5c7b37');
	gr.update();
}

 

 

2. When SLA completes 100% then , additional comments should be added to RITM and catalog task :

 

 

var tgr = new GlideRecord('sc_task');
tgr.addQuery('sys_id',current.sys_id);
tgr.query();
while(tgr.next())
{
tgr.work_notes= "Ticket is being escalated to Triage Team. No additional actions are required";
tgr.update();
}

 

 

 

But these run script are not running properly, after 75% I can not see change in assignment group and after 100% I cannot see additional comments(work notes) neither  in RITM nor in catalog task.

 

Can anyone suggest where I am making mistake.

 

Thanks in advance.

1 REPLY 1

Daniel Borkowi1
Mega Sage

Hi @Abhijit Das7, can you please check the second script. I think the second line should be (assumption SLA runs on the task which should be reassigned):

tgr.addQuery('sys_id',current.task.sys_id);

 Greets
Daniel

Please mark reply as Helpful/Correct, if applicable. Thanks!