How to "find" the work_notes of a Catalog Task?

Jack42
Kilo Expert

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.

find_real_file.png

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

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

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";

}

Regards
Harish

View solution in original post

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron

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";

}

Regards
Harish

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!

you can remove that line..it will actually pull my variable called "comments" from the form

Regards
Harish