workflow approvals should create
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
There is a catalog item and in that there are 2 fields one is "group name" referring to group table and another one is radio buttons field (select_action) conatins 4 options
if "select_action" variable selected "update approval deputies" or "update mailbox" then approval should goes to selected group manager.
if "select action" variable selectes "deactivate a group" or "other" then two approvals should create
1. group manager approval and second approval is "L2 group approval"
if group does not have manager then the entore request should be cancelled.
how can i achieve this in workflow.
(backened names )
if (axa_sesd_select_action_var = Update approval deputies OR Update Mailbox)
then only group manager approval (the group selected in the above field)
if(axa_sesd_select_action_var = Desactivate a group OR Other)
then 2 approvals should trigger
one is selected group manager approval and second one is default group (L2 group)
if selected group does not have manager then request should be cancelled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
it's an easy requirement.
what did you start with and where are you stuck?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
HI @Ankur Bawiskar ,
I have written a approver user script but no approvals are triggering
answer = [];
var groupName = current.variables.axa_sesd_group_name_var;
var grp = new GlideRecord('sys_user_group');
if (grp.get(groupName)) {
if (!grp.manager) {
current.state = 4;
current.work_notes = "Selected group has no manager.";
current.update();
answer = [];
return;
}
answer.push(grp.manager.toString());
var action = current.variables.axa_sesd_select_action_var + '';
if (action == 'Desactivate a group' || action == 'Other') {
// L2 approver user sys_id
answer.push('981c4bbd87b0c6908530fd99cebb35e6');
}
}
please suggest what is wrong here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
my thoughts
-> Use getDisplayValue() or ensure you compare against the actual choice values (not labels).
-> Use toString() on the manager reference.
-> Don’t manually set state = 4 inside the approver script; instead, let the workflow handle cancellation when no approvers are returned.
try this
// Approver User Script (Advanced Approval - User activity)
answer = [];
var groupName = current.variables.axa_sesd_group_name_var; // sys_id of sys_user_group
if (!groupName) {
// No group selected -> no approvers
return;
}
var grp = new GlideRecord('sys_user_group');
if (!grp.get(groupName)) {
// Group not found -> no approvers
return;
}
// If group has no manager, return no approvers (workflow will cancel later)
if (!grp.manager) {
// Do NOT set state here; just return empty answer
return;
}
// Add group manager as first approver
answer.push(grp.manager.toString());
// Get selected action (ensure you compare with the actual choice values)
var action = current.variables.axa_sesd_select_action_var + '';
// Adjust these values to match your choice list values (not labels)
// Example: if your choice values are: update_deputies, update_mailbox, deactivate_group, other
if (action == 'Desactivate a group' || action == 'Other') {
// L2 approver sys_id
var l2Approver = '981c4bbd87b0c6908530fd99cebb35e6';
answer.push(l2Approver);
}
// answer now contains 1 or 2 approvers
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @sinu2 ,
Are you using a flow designer flow or a workflow? , we would recommend to you use flow and below is the high level flow logic.
Hope it helps!
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025,2026
