- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 03:42 PM
Hi _ looking to copy or push task notes and comments to the incident notes and comments field. I would like the Incident Assigned To person to be able to view the task notes from the incident record without switching back and forth.
I copied a BR and tried to tweak to perform the action I needed, but it's not working. Any help would be greatly appreciated.
This is the br I'm using.
copyCommentsToIncidentWorkNotes();
function copyCommentsToIncidentWorkNotes() {
var commentsChanges = current.comments.changes();
var workNotesChanges = current.work_notes.changes();
var link = new GlideRecord("incident_work_notes_link");
link.addQuery("linked_task", current.sys_id);
link.query();
var ids = [];
while (link.next()) {
if (!link.parent.nil()) {
ids.push(link.parent.toString());
}
if (commentsChanges)
link.comments = current.comments;
if (workNotesChanges)
link.work_notes = current.work_notes;
link.setWorkflow(false);
link.update();
}
var incidentworknotes = new GlideRecord("incident_work_notes");
incidentworknotes.addQuery("sys_id", ids);
incidentworknotes.query();
while (incidentworknotes.next()) {
if (commentsChanges)
incidentworknotes.comments = current.number + ": " + current.comments;
if (workNotesChanges)
incidentworknotes.work_notes = current.number + ": " + current.work_notes;
incidentworknotes.setWorkflow(false);
incidentworknotes.update();
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2018 10:13 AM
No. This script is different. I made few changes to line 8. Use this one.
copyCommentsToIncidentWorkNotes();
function copyCommentsToIncidentWorkNotes() {
var commentsChanges = current.comments.changes();
var workNotesChanges = current.work_notes.changes();
var link = new GlideRecord("incident");
link.addQuery("sys_id", current.parent);
link.query();
var ids = [];
if (link.next()) {
if (commentsChanges)
link.comments = current.comments;
if (workNotesChanges)
link.work_notes = current.work_notes;
link.setWorkflow(false);
link.update();
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2018 04:36 PM
Can you post a screenshot of you task and the script you wrote? Also can you confirm, in the task form, the incident linked has field name as parent?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2018 04:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2018 04:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2018 04:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2018 05:03 PM
Your script is wrong. You need to use this script
copyCommentsToIncidentWorkNotes();
function copyCommentsToIncidentWorkNotes() {
var commentsChanges = current.comments.changes();
var workNotesChanges = current.work_notes.changes();
var link = new GlideRecord("incident");
link.addQuery("sys_id", current.parent);
link.query();
var ids = [];
if (link.next()) {
if (commentsChanges)
link.comments = current.comments;
if (workNotesChanges)
link.work_notes = current.work_notes;
link.setWorkflow(false);
link.update();
}
Please mark this response as correct or helpful if it assisted you with your question.