- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 12:04 PM
how to create auto approval in ServiceNow flow designer if requester is one of approver.
My requirement has 2 level approvals,
1 level will be requested for manager approval and
2.it will be owners' approval where there is a possibility requester is one of approver
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2024 10:52 AM
Thanks for coming forward to help me, somehow i figured out workaound for this,
The requirement was,
for a catalog it suppose to have 2 leve approvals, 1st one will be requested for > manager and the second one will based on owners variable, which contains multiple users.
here there is a probability that requested by may come as owner, in that situation second level approval shoul auto approve .
I've achieved this with the help of action called "Script".
I have created a action and selected Script as step. and provided input variables as opened by and Owners.
and the logic used "Owners Includes opened by"
1.if it returns false then goes ahead create 2nd level approval for all owners.
2. if it returns true then it creates an approval record with state approved and approver as opened by.
Below script i have used
(function execute(inputs, outputs) {
// Extract the `openedby` sys_id
var openedbySysId = inputs.openedby;
// Extract the `owners` array of sys_ids (assuming it's a string of comma-separated sys_ids)
var ownersArray = inputs.owners.split(',').map(function(id) {
return id.trim();
});
if (ownersArray.includes(openedbySysId)) {
//gs.info("Opened by user is one of the owners.");
outputs.owner = true; // Return true if the openedby user is one of the owners
} else {
//gs.info("Opened by user is NOT one of the owners.");
outputs.owner = false; // Return false if the openedby user is not in the owners list
}
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2025 09:07 PM - edited 08-24-2025 09:08 PM
You can also use a before Business rule on sysapproval_approver table, check if
approval for's task type is req_item &
approval for's item is <the catalog item> &
approver = approval for.requested item.requested_for &
state=request
if matches, set state to approved