- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 07:48 AM
I'm working on a (relatively) simple workflow which creates 2 catalog tasks:
1. First task, send to support group manager for approval and comments in the "work notes" field.
2. Second task to server admins for action
The second task needs to include the work notes from the first field. What's a simple way to accomplish this?
Thanks,
Selena Smith
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2016 09:32 AM
Ahhh... See that is the problem, I was assuming this is on the sc_req_item all the way. Change your script to this, hopefully it will work now.
task.work_notes=pullComments();
function pullComments(){
var comments=[];
var gr= new GlideRecord("sc_task");
gr.addQuery("request",current.getValue("sys_id"));
gr.query();
while(gr.next()){
comments.push(gr.work_notes.getJournalEntry(-1));
}
return comments.join();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 11:04 AM
Still nothing.
Here's the section of my workflow in question (should be fairly simple):
The first task script:
The second task script:
I also tried it with the scratchpad variable, adding this to the first task:
workflow.scratchpad.worknotes = task.work_notes;
And in the second task:
task.work_notes = workflow.scratchpad.worknotes;
But nothing was copied to the second task and no errors generated. I'm thinking it should be added at the completion of the task but I'm just not sure how that's done.
My apologies for all the questions, I'm fairly new to ServiceNow - we went live June 7th and up to this point have done only simple workflows.
Thanks for all your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 11:21 AM
I have tested this on my instance and is working as expected. Can you see the activity log of the second catalog task, you should see the work_notes from previous task there. For testing purposes put few log statements a shown below ans see in the logs if you can find these in the logs.
task.work_notes=pullComments();
function pullComments(){
var comments=[];
var gr= new GlideRecord("sc_task");
gr.addQuery("request_item",current.getValue("sys_id"));
gr.query();
while(gr.next()){
gs.log("From workflow "+ gr.number);
comments.push(gr.work_notes.getJournalEntry(-1));
gs.log("From workflow "+ gr.work_notes.getJournalEntry(-1));
}
gs.log("From workflow final return "+comments.join());
return comments.join();
}
Here in the snapshot, you can see the work_notes from previous task copied to the current task and they are shown in the activity log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 11:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 11:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 11:57 AM