
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2017 03:26 PM
We have 3 tasks. I am trying to copy entire activity from task1 to task2, and task2 to task3. I need work notes and comments to be carried over.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 11:27 AM
Okay, I created the following Business Rule and it worked for me.
Type: before, insert
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_task');
gr.addQuery('parent', current.parent.sys_id); // Get an sc_task with the same parent as the current one
gr.orderByDesc('sys_created_on');
gr.query();
if (gr.next()) {
current.comments = gr.comments_and_work_notes.getJournalEntry(-1);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2017 04:31 PM
Below post has code to copy activity.
This will be helpful to you
How to copy activity log from Incident to Problem
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 11:27 AM
Okay, I created the following Business Rule and it worked for me.
Type: before, insert
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_task');
gr.addQuery('parent', current.parent.sys_id); // Get an sc_task with the same parent as the current one
gr.orderByDesc('sys_created_on');
gr.query();
if (gr.next()) {
current.comments = gr.comments_and_work_notes.getJournalEntry(-1);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 12:04 PM
Please mark answer as correct so that others can benefit from similar question.
Regards,
Sachin