- 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-12-2018 09:13 AM
The first script you gave me doesn't do copy the task notes to the incident.
Could I be missing a get statement?
The below script that you gave me (which was the 2nd script you told me to use) works, but it copies the task notes to every incident in my instance:
copyCommentsToIncidentWorkNotes();
function copyCommentsToIncidentWorkNotes() {
var commentsChanges = current.comments.changes();
var workNotesChanges = current.work_notes.changes();
var link = new GlideRecord("incident");
link.addQuery("linked_task", current.sys_id);
link.query();
var ids = [];
while (link.next()) {
if (commentsChanges)
link.comments = current.comments;
if (workNotesChanges)
link.work_notes = current.work_notes;
link.setWorkflow(false);
link.update();
}

- 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.