Copy comments from RITM to SCTASK

Sam198
Mega Guru

Hi all,

I have below BR to copy RITM comments to SCTASK, this comments get copied to all open and closed sctask with below, i would like to change/add text where it says "Task closure note" - how do i change my code?

find_real_file.png

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

// Add your code here
var gr_task = new GlideRecord('sc_task');
gr_task.addQuery('request_item',current.sys_id);
gr_task.query();
while(gr_task.next()){
gr_task.comments = current.comments.getJournalEntry(1);
gr_task.update();
}

})(current, previous);

 

 

1 ACCEPTED SOLUTION

Hi there,

If we go from a Business Rule which runs on a update on the sc_task, consider something like below. Tested and works.
You do have to tweak it a little bit! I don't like the before part, and I didn't set any condition on the Business Rule.

Kind regards,
Mark

find_real_file.png

find_real_file.png

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

	var grCatalogTask = new GlideRecord('sc_task');
	grCatalogTask.addQuery('parent', current.parent);
	grCatalogTask.addQuery('sys_id', '!=', current.getUniqueValue());
	grCatalogTask._query();

	while(grCatalogTask._next()) {
		grCatalogTask.work_notes.setJournalEntry('Copied comment from ' + current.number + ':' + '\n' + current.work_notes.getJournalEntry());
		grCatalogTask.update();
	}

})(current, previous);

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

10 REPLIES 10

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,


Just to clarify, do you want to remove that "Task closure note" ?


Thanks,
Ashutosh