Update the Parent Incident worknotes when an Incident Task is Closed complete

Manon
Kilo Contributor

Hello,

I am trying to create a Business Rule so that when an Incident Task state changes to "Closed complete", the parent's owner is informed of this closure through the work notes.

Below is the Business Rule I created, however it is not working and I can't seem to find a correct script to make it work:

find_real_file.png

The script:

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

	// Add your code here
	current.parent.work_notes="The Incident Task " + current.number + " has been completed.";
	
	/*var gr = new GlideRecord('incident');
	gr.addQuery('sys_id',current.parent);
	gr.query();
	
	gr.work_notes="The Incident Task " + current.number + " has been completed.";*/
	
})(current, previous);

Any idea of how I could make this BR work?

Thank you in advance!

1 ACCEPTED SOLUTION

Manon,

Can you try the below code, it should work for sure

var parent = current.parent;

var gr = new GlideRecord('incident');
gr.addQuery('sys_id',parent); //gr.addQuery('sys_id',parent.toString());
gr.query();
if(gr.next()){


	gr.work_notes="The Incident Task " + current.number + " has been completed.";
	gr.update();
}

 

Please mark as correct if this helps!!!

-Vinay.

View solution in original post

13 REPLIES 13

i tried that but i stuck on loop to update child to parent and parent to child work notes updation

Knight Rider
Mega Guru

Hi Manon,

You forgot to include gr.update();

Replace your code with below

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

	// Add your code here
	
	var gr = new GlideRecord('incident');
	gr.addQuery('sys_id',current.parent);
	gr.query();
	
	gr.work_notes="The Incident Task " + current.number + " has been completed.";
	gr.update();
	
})(current, previous);

 

Thanks,

-Vinay.

Thank you for your quick answer, but event when adding gr.update() nothing happens...

Could you please tell me on which table you  are writing this business rule/

 

-Vinay.

I'm writing this business rule on the table u_incident_task (we don't use the table incident_task), which I believe we created.