
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 06:41 PM
Dear now Community Members,
I seem to be unable to "find" the work_notes of my Catalog Task. :'(
The approach is to display the work_notes of a Catalog Task in the Approval - User request.
To set the work_notes I've already found a solution (link -> Adding approval comments from the workflow), by branching before creating the approval. In the branch I wait for a few seconds (while the approval is created) then update with a GlideRecord in a Run Script.
Q: How can I get the work_notes of the Catalog Task?
Many thanks in advance,
Jack
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 07:01 PM
You can add a run script after your catalog task getz closed and in run script use the code below
Modify your logic
var target = new GlideRecord('sc_task');
target.addQuery('parent', current.sys_id);
target.addInactiveQuery();
target.query();
if (target.next()) {
//grab work_notes from this task and need to rewrite to request with variables
var my_work_notes = '';
var notes = target.work_notes.getJournalEntry(1);
var lines = notes.split('\n');
for (i = 0; i < lines.length; i++) {
if ((lines[i].indexOf('(Work notes)') == -1) && lines[i].length > 0)
my_work_notes += lines[i]+'\n';
}
my_work_notes += "Comments: \n";
my_work_notes += "\t" + current.variables.comments + "\n";
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 07:01 PM
You can add a run script after your catalog task getz closed and in run script use the code below
Modify your logic
var target = new GlideRecord('sc_task');
target.addQuery('parent', current.sys_id);
target.addInactiveQuery();
target.query();
if (target.next()) {
//grab work_notes from this task and need to rewrite to request with variables
var my_work_notes = '';
var notes = target.work_notes.getJournalEntry(1);
var lines = notes.split('\n');
for (i = 0; i < lines.length; i++) {
if ((lines[i].indexOf('(Work notes)') == -1) && lines[i].length > 0)
my_work_notes += lines[i]+'\n';
}
my_work_notes += "Comments: \n";
my_work_notes += "\t" + current.variables.comments + "\n";
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 07:58 PM
Hello harishkumar,
Thank you so much for the fast reply.
Your script does the trick! (if you combine it with the Adding approval comments from the workflow method mentioned above.)
The following line however returns 'UNDEFINED'..
my_work_notes += "\t" + current.variables.comments + "\n";
..but the for-loop delivers the work_notes!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 08:02 PM
you can remove that line..it will actually pull my variable called "comments" from the form
Harish