Populate has breached value of task_sla to sc_task custom field Ticket tat

sanasayyad
Tera Contributor

To achieve this, I ran a Fix Script which executed successfully. Now, I want to create a Business Rule for future updates. I tried implementing it, but it's not working as expected.

I wrote an After Update Business Rule on the task_sla table with the following condition:
"Has Breached" changes to true AND Task starts with 'SCTASK'.

However, the logs show:
The task name is undefined

I also waited for the SLA to breach, but still there’s no output.
Could someone please help me review the Business Rule?

 

(function executeRule(current, previous /*null when async*/) {

    // Only continue if the related task is of type sc_task
	gs.addInfoMessage("hello");
	var taskname = current.task.getDisplayValue();
	gs.info("the task name is" +taskname);

    // Get the most recent SLA record for the task
    var scTask = new GlideRecord('sc_task');
	scTask.addEncodedQuery('number='+taskname);
	scTask.query();

	if(scTask.next())
	{
		scTask.u_ticket_tat = current.has_breached;
		gs.info("sc task has been updated" +scTask.u_ticket_tat);
		scTask.update();

	}
  
})();

1 ACCEPTED SOLUTION

J Siva
Tera Sage

Hi @sanasayyad 
Change your Business rule condition & script as below

JSiva_0-1749037901949.png

 var scTask = new GlideRecord('sc_task');
 scTask.get(current.task.sys_id);
 scTask.u_ticket_tat = true;
 scTask.update();

Regards,
Siva

View solution in original post

2 REPLIES 2

sanasayyad
Tera Contributor

please someone guide 

J Siva
Tera Sage

Hi @sanasayyad 
Change your Business rule condition & script as below

JSiva_0-1749037901949.png

 var scTask = new GlideRecord('sc_task');
 scTask.get(current.task.sys_id);
 scTask.u_ticket_tat = true;
 scTask.update();

Regards,
Siva