- 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-03-2019 04:20 AM
Hi,
Yes this is correct
: " that you want to copy the last comment of a task, to all other tasks. Where the issue being, the comment is also copied to the task where this comment is from?" - This is the query.
Thanks in advance.

- 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-09-2019 11:46 AM
Hi there,
Did this work for you? Or do we need to follow-up on this?
If my answer helped you in any way, please then mark it as helpful.
Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.
Kind regards,
Mark
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-10-2019 08:31 AM
Hi there,
Did this solve your issue? Or do we need to follow up on this?
Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.
Kind regards,
Mark
---
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-11-2019 12:50 AM
Hi Mark,
Sorry did not had chance to look at this one, been busy with some other stuff and other issues.
The above script seems to fit my requirements so i will mark that as correct.
Thanks again.