Approval based on condition in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2025 06:35 AM
I have a field called server which is of list collector type referencing to server table. Now if the server selected in catalog item has a change control group value not empty then approval should go to change control group. If server selected has change control group value empty then approval should got to owned by user of the server.
If suppose 2 server are selected and 1 server has change control group value and other server has owned by value then approval should go to both group and user
How to implement this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2025 06:19 AM
why are you creating approval record via script?
you should use workflow approval activity and then use it to set that
Approval - User workflow activity
var server = current.variables.server_name.toString();
gs.log("server name" + server);
var approverGroups = [];
var approverUsers = [];
var gr = new GlideRecord('cmdb_ci_server');
gr.addQuery('sys_id', 'IN', server);
gr.query();
while (gr.next()) {
if (gr.change_control) {
var groupID = gr.change_control.toString();
if (approverGroups.indexOf(groupID) == -1)
approverGroups.push(groupID);
} else if (gr.owned_by) {
gs.log("in else if");
var userID = gr.owned_by.toString();
if (approverUsers.indexOf(userID) == -1)
approverUsers.push(userID);
}
}
answer = [];
answer = approverGroups + ',' + approverUsers;
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2025 06:25 AM
But if I use User approval activity then for the group approval, approval will be waitiing to be approved from all members of the group.
I do not want that, like only 1 member of the group approves then the RITM should be approved