how to send approval to application owner in workflow?

Gudu
Tera Contributor

Hi Team, 

Gudu_0-1753803573158.png

 

Hi Developers, 

In a catalog, when i click on select the cmdb application(reference to table - cmdb_ci_appl) , it is auto populating the values of each field. 

Now in workflow, i want to send the approval to application owner as first level approval. 

Could anyone please do let me know what will be the code i need to write for this. in workflow script.

 

1 ACCEPTED SOLUTION

harish41
Tera Guru

Hi,

If the Application Owner field is a reference field on the form, then you can use below script in Approval activity in workflow.

answer = [];
answer.push(current.variables.application_owner); 


If not reference field, you can use below script  

answer = [];
var gr = new GlideRecord("sys_user");
gr.addQuery("name", current.variables.application_owner);
gr.query();
if (gr.next()) {
    answer.push(gr.getUniqueValue());
}

 

Mark as correct and helpful if it solved your query.

Regards,
Harish

View solution in original post

4 REPLIES 4

Laveena-Agarwal
Kilo Sage

Hi @Gudu 

Follow this article, it has step by step approach - Article #9 - Create User Approvals using Catalog V... - ServiceNow Community

harish41
Tera Guru

Hi,

If the Application Owner field is a reference field on the form, then you can use below script in Approval activity in workflow.

answer = [];
answer.push(current.variables.application_owner); 


If not reference field, you can use below script  

answer = [];
var gr = new GlideRecord("sys_user");
gr.addQuery("name", current.variables.application_owner);
gr.query();
if (gr.next()) {
    answer.push(gr.getUniqueValue());
}

 

Mark as correct and helpful if it solved your query.

Regards,
Harish

prerna_sh
Mega Sage

Hi @Gudu 

Follow these articles:
Simple approvals in workflow - Support and Troubleshooting
Solved: Script for user approval in catalog workflow - ServiceNow Community

If my response solves your query, please marked helpful by selecting Accept as Solution and Helpful. Let me know if anything else is required.
Thanks,
Prerna

Ankur Bawiskar
Tera Patron
Tera Patron

@Gudu 

in workflow user approval activity you can use this advanced script

answer = [];

answer.push(current.variables.ownerVariableName); // this variable should be referring to sys_user

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader