Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Script Variables in workflow

Andy Pickles
Tera Contributor

Hi All,

Im making a workflow for a request.

Its all working well but im struggling with one bit ..

 

There is an approval widget and the 'approved' branch then goes to a new catalog task.

In that catalog task, I want to reference the name of the person who approved it.

So for example, somewhere in the description of the catalog task , i would like a line that says "this has been approved by xxxx"

But i cant find a way to reference the approvers name - can anyone help me with a way to achieve this please ?

Many thanks

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,

There can be one person approving it or more than 1 also approving it for say Group Approval is there are any. So I would suggest here is write a Script in the Advanced section of your Catalog task activity and use the script below:

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval',current.sys_id);
gr.addQuery('state','approved');
gr.query();
while(gr.next()){
task.description = 'This Request has been approved by ' + gr.getDisplayValue('approver');
}

Use this script in the screenshot below in Catalog Task activity itself:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

5 REPLIES 5

This works perfectly - thank you