- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 09:41 PM
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?
(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);
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2019 10:17 PM
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
(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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 10:26 PM
Hi,
Just to clarify, do you want to remove that "Task closure note" ?
Thanks,
Ashutosh