- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2016 12:03 PM
Hi,
I was wondering if anyone had a quick tip on how to copy the activity log from parent to underlying tasks? Lets say you've been working on an incident and after a while find out you need to create a task and send to an external vendor. When I create the task i want all information from activity log to be updated on the tasks actiity log too..
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2016 01:11 PM
I got it working using this BR:
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent.sys_id);
gr.query();
if (gr.next()) {
var comments = gr.comments.getJournalEntry(-1);
current.comments = comments;
//gs.addInfoMessage('Old log:' + comments);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2016 12:27 PM
Are you looking to grab the existing comments and copy them down or have all future comments added to the Incident copy to the task?
If existing comments, you should be able to include 'comments' in your script and put it into the 'comments' on your task.
If continuing to copy, you should create a Before Update business rule on your Incident table, with the condition "Additional comments" "changes". Then in the advanced tab script field, write a script similar to this (this one copies the comments from sc_task to the sc_req_item:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_req_item');
gr.get(current.request_item);
gr.comments = current.comments;
gr.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2016 01:11 PM
I got it working using this BR:
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent.sys_id);
gr.query();
if (gr.next()) {
var comments = gr.comments.getJournalEntry(-1);
current.comments = comments;
//gs.addInfoMessage('Old log:' + comments);
}