- 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 10:13 AM
Hi Selena,
workflow.scratchpad.wknotes = task.work_notes; should be added in the task from which work notes needs to be copied.
You can retrieve the scratchpad variable in any task that follows simply by mentioning:
var abc = workflow.scratchpad.wknotes;
Using the Workflow Scratchpad - ServiceNow Wiki
Let me know if that works.
Kind regards,
Sourabh D

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 12:19 PM
What do you see form the logs that you placed in the script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 12:43 PM
Did you try to see the logs to know if the script is working properly or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 12:48 PM
I'm not sure where the logs are located

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 01:12 PM
If you have not changed, first change your script in the task activity to this
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();
}
Then publish your workflow, then order that item again and close the task1 so that task2 is created. Now go to the logs as shown below
Type Script log in the navigator and open the module as shown below and add a filter condition which says Message contains From workflow.