john_duchock
Kilo Guru

The following are business rules we use to copy work notes and comments from the request task to the parent requested item record.  Hopefully these will be useful for other folks as well...

//Name: Copy comments from TASK to RITM
//Table:  sc_task
//Advanced:  true
//When:  Before Update; Additional Comments <changes>
//Condition:  current.comments.changes() && current.comments.indexOf('Comment added from:') < 0;
//  Note that the condition prevents the note from copying multiple times.

//Script:

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

	if(current.comments.nil()){
		return;
	}	

	else {

		var gr = new GlideRecord('sc_req_item'); 
		gr.addQuery('sys_id',current.request_item);
		gr.query();
		while(gr.next()){
			gr.comments = "Comment added from: " + current.number + " | " +current.request_item.cat_item.name + "\n >>>  " +current.comments;
			gr.update();
		}
	}
})(current, previous);

 

//Name: Copy work notes from TASK to RITM
//Table:  sc_task
//Advanced:  true
//When:  Before Update; Work Notes <changes>
//Condition:  current.work_notes.changes() && current.work_notes.indexOf('Work Note added from:') < 0;
//  Note that the condition prevents the note from copying multiple times.

//Script:

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

	if(current.work_notes.nil()){
		return;
	}	

	else {

		var gr = new GlideRecord('sc_req_item'); 
		gr.addQuery('sys_id',current.request_item);
		gr.query();
		while(gr.next()){
			gr.work_notes = "Work Note added from: " + current.number + " | " +current.request_item.cat_item.name + "\n >>>  " +current.work_notes;
			gr.update();
		}
	}
})(current, previous);

 

Cheers !

Comments
SNOWSBC24
Tera Contributor

Hi John,

I have requiremnt for, 

Roll up of work notes from sub-task to task

Roll up of work notes from task to sub-projects

Roll up of work notes from sub-projects to the master projects

Identifier of rolled up work note that which task/sub-tasks or sub-project it actually belongs to.

somasekharK
Tera Contributor

Hi ,

If we use above script for after Business rule, we face any issues?

Luiz Lucena
Mega Sage

Hi @somasekharK 

We did something like that. Because fulfillers work on the SCTASKs and most of them don't like to jump up to the RITM to read any additional information added by user from Service Portal.

So, we had to create 2 Business Rules, one on the RITM (to copy comments to the SCTASK) and another in the SCTASK to copy comments to the RITM.
But must be careful, otherwise it get duplicating easily.

Tfnhodgi
Tera Contributor

Hey, do you have a script that would work with adding comments from an Approval record to the parent RITM?

These scrips worked for me and anything I am finding related to this is not working. I wonder if it is possible how we have our approval process setup?

Version history
Last update:
‎10-16-2020 05:27 AM
Updated by: