- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 08:08 AM
Is there a script available that copies the worknotes entered on a catalog task back to the parent RITM record? We are using the RITM record to provide status back to the users via the portal.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 08:15 AM
Hi James,
Nothing out of the box, but you could create a business rule that does this easily enough.
Name: Copy task work notes to RITM
Table: Task (sc_task)
Insert: checked
Update: checked
When: After
Advanced: checked
Condition: Work notes Changes (or in the condition field: current.work_notes.changes())
Script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_req_item');
if (gr.get(current.parent)) {
gr.work_notes = current.work_notes;
gr.update();
}
})(current, previous);
You said work notes. Change to 'comments' where appropriate if that's what you meant.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2016 07:35 AM
Thanks Joshua. You are correct. The BR is firing. ==> indicates it entered the BR, <== means it exited.
Try this to copy the work notes on line 5... I didn't see it before, sorry.
gr.work_notes = current.work_notes.getJournaleEntry(1);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2016 08:14 AM
I'm getting some extra string timestamp data but i should be able to substring that out without issue.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2016 08:15 AM
Pardon my typo. I hope you caught it. I had an extra 'e' on getJournalEntry()
gr.work_notes = current.work_notes.getJournalEntry(1);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2016 09:25 AM
I did sir. Since I doubt I'm the only person who'll want to do this in Helsinki Patch 4, I've included the updated code that is working for me now (strips out the system generated gobbley gunk):
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_req_item');
if (gr.get(current.request_item)) {
// Initialize Variables to be Used
var tempnote, n, length, goodnote = '';
// Put the Most Recent Work Note into a temporary variable
tempnote = current.work_notes.getJournalEntry(1);
// Grab the position of the last part of the string in the system generated timestamp/etc
n = tempnote.lastIndexOf('(Work notes)') + 13;
// Determine that length of the string
length = tempnote.length;
// Slice out the system generated timestamp/etc (start of timestamp to end of string)
goodnote = tempnote.slice(n,length);
// Put the cleaned up version of the work notes into the RITM
gr.work_notes = goodnote;
// Update the RITM record.
gr.update();
}
})(current, previous);
Hopefully others can find this to be helpful.
Thanks again Chuck. I owe you a bow-tie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2016 06:59 AM
A slight issue.
When the final task is closed it's not automatically changing the state to 'Closed Complete'. I'm guessing this update is conflicting with the system behavior for some reason. Any ideas?