Updating a field on Incident form, when a Task_SLA breaches.

RajanMurkute
Mega Guru

I want to update a fields on Incident form, when a task_SLA breaches. There's a workflow associated with the SLA.

When SLA is breached, I want the workflow to (1) reset (update) a field ('State') on Incident form to ''Active' and (2) update the work notes on Incident form to t

To update fields using the workflow activity 'X =Set  Values', I tried by selecting appropriate fields in the drop-down boxes and picking up task-related fields for State and work-notes. But that didn't work.

find_real_file.png

Then I tried using the following script - 

var parent_incident = new GlideRecord('incident');
parent_incident.addQuery('sys_id',current.parent.sys_id);
parent_incident.query();

parent_incident.next();
parent_incident.state = 2;   // 2 - value for 'Active'
parent_incident.work_notes = "State reset to 'Active' by workflow";

parent_inc.update();

I still can't update the Incident record (fields 'State' and 'Work notes'). Can someone help?

 

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

you can add run script on sla workflow with something like

var inc = new GlideRecord('incident');

inc.get(current.task);
if(inc.sys_class_name == 'incident'){

inc.work_notes = "State reset to 'Active' by workflow";

inc.state = 2;

inc.update();

}

View solution in original post

3 REPLIES 3

Mike Patel
Tera Sage

you can add run script on sla workflow with something like

var inc = new GlideRecord('incident');

inc.get(current.task);
if(inc.sys_class_name == 'incident'){

inc.work_notes = "State reset to 'Active' by workflow";

inc.state = 2;

inc.update();

}

Worked first time like a champ!  Thanks

RajanMurkute
Mega Guru

Thanks a lot, Mike! Used the script you gave and it worked right away. I am very pleased. Thanks, again.