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

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

Anil Lande
Kilo Patron

Hi,

In your catalog task activity your can use advance script part and use GlideRecord query to get approver name.

var approverName='';
var appGr = new GlideRecord('sysapproval_approver');
appGr.addQuery('sysapproval_approver',current.sys_id.toString());
appGr.addQuery('state','approved');
appGr.orderByDesc('sys_updated_on');
appGr.query();
if(appGr.next()){
approverName.appGr.approver.getDisplayValue();
}

If the your catalog request is having only one approval before (not group approval) before this task is generated then you can use the same script which you have used to set approval to get approver name. Like requested for manager (because he is the only approver )

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Jaspal Singh
Mega Patron
Mega Patron

Hi Andy,

 

In the Catalog task activity try below.

var getapprovedby=new GlideRecord('sysapproval_approver');
getapprovedby.addQuery('sysapproval',current.sys_id);
getapprovedby.orderByDesc('sys_updated_on');
getapprovedby.addQuery('state','approved');
getapprovedby.setLimit(1);
getapprovedby.query();
if(getapprovedby.next())
{

current.short_description='Record is approved by '+getapprovedby.approver.getDisplayValue();

}

 

Nayan Mahato
Tera Guru

Hi Andy Pickles,

In the catalog task activity click on the advance check box and after that in the script section, you can query "sysapproval_approver" table and find the approval name like below.

find_real_file.png

 

Regards,

Nayan

 

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