- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 08:43 AM - edited 07-29-2025 08:45 AM
Hi Team,
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 09:10 AM - edited 07-29-2025 09:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 08:57 AM
Hi @Gudu
Follow this article, it has step by step approach - Article #9 - Create User Approvals using Catalog V... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 09:10 AM - edited 07-29-2025 09:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 09:10 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 09:19 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader