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

Still nothing.  



Here's the section of my workflow in question (should be fairly simple):



find_real_file.png


The first task script:


find_real_file.png



The second task script:



find_real_file.png



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!


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


find_real_file.png


Here's what I see in the Activity Stream for the 2nd catalog task:


find_real_file.png


Can you click this filter icon to see if you have the work_notes checked


find_real_file.png


Yes, work notes are visible


find_real_file.png