How to Skip Service Catalog Approval if Manager is opening a Request Item?

Naresh_5120
Tera Contributor

I am working to modify our existing on-boarding Catalog form. Here on our form we have field called "Manager (Employee's direct supervisor).

What I am  looking for  is when a manger himself is opening a request then it should skip the Service Catalog Approval process and create a task , Otherwise if request is opened by someone else it should trigger approval process to manager mentioned in "Manager " field. In order to achieve this i have tried below mention script but somehow it skipping the approval in both scenario, when raised by manager or by others.

answer = ifScript();

 

function ifScript() {

 

var manager = current.variables.nh_manager;

 

var openedBy = current.opened_by;

 

if (manager == openedBy) {

 

return 'yes';

 

} else{

 

return 'no';

 

}

}

 

 On - Boarding form example

find_real_file.png

Variable name of Manager field

find_real_file.png

Can anyone help what I am missing to achieve the desired results. I am new to ServiceNow so my scripting not that advance.

Thanks & Regards,

Naresh 

 

8 REPLIES 8

Hi Prateek,

 

Thank you for helping me with this script. After using this script in both cases (request raised by Manager & Others) Catalog Item is triggering approval workflow but it does not show the approver name.

I think we have to see that user (sys_user) id mentioned in Manager field  and opened_by should be same then only it will skip the manager approval.

In variable nh_manager I have selected type is reference which pulls users from sys_user 

 

find_real_file.png

 

find_real_file.png

I dont see any approval record in your screenshot.

The stage you are point in the screenshot needs to be adjusted at the WF level.

Can you show how the workflow looks like?


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

vinothkumar
Tera Guru

Create a business rule on approval table as below, I tried similar, auto approve if requestor for is the  manager, then auto approve.

 

You have to simply modify the logic

 

find_real_file.png

 

 

In action

 

find_real_file.png

Hi vinothkumar,

I also have same issue. I need to exclude BR for some catalog items. The scenario is, For approver "xyz" all approval request's for all catalog items should be auto approve except catalog item  "abc".  So I did'nt understand how to get catalog item name in when to run filter list of business rule.