- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 07:31 AM
Hi All,
I was doing one development but there is some issue with the approval.
On catalog Item, there are a few variables
1- Opened By [opened_by]
2- For Whom? [for_whom]
3- etc...
I need to skip the approval in workflow following the below condition -
No Approval Required When:
User in the variable "Opened by" = "For Whom?"
OR
Manager of User in the variable "For Whom?" = "Opened By"
Regards,
Piyush
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 08:19 AM
Hi,
you can use Workflow IF Activity
-> output of yes means approval is required
-> output of no means skip approval
Something like this
answer = ifScript();
function ifScript() {
var gr = new GlideRecord("sys_user");
if(gr.get(current.variables.for_whom)){
var manager = gr.manager.toString();
var openedUser = current.variables.opened_by.toString();
if(openedUser == current.variables.for_whom.toString() || openedUser == manager)
return 'no';
else
return 'yes';
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 07:46 AM
Hi Piyush,
You need to modify the workflow that is being used in the catalog item.
Add an If activity before the approval.
Script will look something like:
answer = approvalNeeded();
var user = current.variables.for_whom; //Is this a sys id? / Reference field?
var userRecord = new GlideRecord('sys_user');
userRecord.get(user);
var manager = userRecord.manager.toString();
function approvalNeeded() {
if (current.variables.opened_by.toString() == current.variables.for_whom.toString() || current.variables.opened_by.toString() == manager) {
return 'no';
}
return 'yes';
}
Workflow will look something like:
PPlease mark answer as helpful/correct based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 08:19 AM
Hi,
you can use Workflow IF Activity
-> output of yes means approval is required
-> output of no means skip approval
Something like this
answer = ifScript();
function ifScript() {
var gr = new GlideRecord("sys_user");
if(gr.get(current.variables.for_whom)){
var manager = gr.manager.toString();
var openedUser = current.variables.opened_by.toString();
if(openedUser == current.variables.for_whom.toString() || openedUser == manager)
return 'no';
else
return 'yes';
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 10:26 PM
I want to add this to all my workflows which ever is having manager approval in our instance.
If opened by is a manager of requested for then the manager Approval should be skipped.
is there a simplest way to do that?