The CreatorCon Call for Content is officially open! Get started here.

In a workflow, how to pull work notes from one catalog task to another?

selenasmith
Kilo Contributor

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

1 ACCEPTED SOLUTION

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();


}


View solution in original post

30 REPLIES 30

Abhinay Erra
Giga Sage

In the advanced script section of the second task activity, use 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()){


comments.push(gr.work_notes.getJournalEntry(-1));


}


Thanks.   I received an error message on the task -


org.mozilla.javascript.WrappedException:   Wrapped ReferenceError: "next" is not defined


Hello Abihnay, I am dealing with a similar issue and can't seem to solve it. Could you help me out? Here the community post I created: https://community.servicenow.com/message/1269538?et=watches.email.thread#1269538


Hi,

Above script is working, but producing duplicate work notes, can you assist how to stop this

Thank you in advance

 

Piotr