How to copy entire activity from one task to another task?

Not applicable

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.

1 ACCEPTED SOLUTION

Not applicable

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);


View solution in original post

3 REPLIES 3

sachin_namjoshi
Kilo Patron

Below post has code to copy activity.


This will be helpful to you



How to copy activity log from Incident to Problem



Regards,


Sachin


Not applicable

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);


Please mark answer as correct so that others can benefit from similar question.



Regards,


Sachin