How to setup a manager approval for all employees irrespective of their designation

Deeplaxmi
Tera Contributor

Hi All,

 

I want to setup a manager approval for all employees irrespective of their designation in a catalog item

 

What I have done so far is as below :

Now I did not modify any item workflow as its a common workflow used for many catalog items.

So as advised, I am using approval definition.

 

So I created an approval type named "Manager approval for all users zyz"

I selected Type = script and Script output = User(s).

I tried below different codes but no luck. And then I created an approval definition with type = "predefined approval type" and for predefined approval field, I selected the above created approval type as "Manager approval for all users zyz".

 

Below codes tried by me for approval type named "Manager approval for all users zyz"

 

(function() {

-> Below Code 1

    /*var requestor = current.requested_for.getDisplayValue();

 

    var manager = GlideUser(requestor).getManager();

 

    if (manager) {

        current.approver = manager;

        current.state = 'requested';

        current.update();}

 

->Below code 2

var approversList = [];

    approversList.push(current.variables.requester_name.manager);

 

    return approversList;*/

 

->Below code 3

 var approversList = [];

    

        approversList.push(current.variables.requested_for.manager);

    return approversList;

 

})();

 

Can you please help me with code or suggest code or let me know what else can be done. Your help is highly appreciated, Thanks !

 

Thank you

5 REPLIES 5

Deeplaxmi
Tera Contributor

Can someone please assist me with this? Is this actually feasible?

SwarnadeepNandy
Mega Sage

Hello @Deeplaxmi,

I would recommend using Flow Designer to achieve this requirement. Code should be the last resort to use in ServiceNow.

Put approval action for all the catalog item flow as mandatory.

In the approval step, select the user's manager as approver for the cat item.

 

Kind Regards,

Swarnadeep Nandy

Hi SwarnadeepNandy,

 

Actually flow designer is not used in my org. and also the workflow is a common workflow used for many other catalog items, so to add anything there is prohibited. The only option I have is "Approval definition".

 

It would really be very helpful if you suggest me related to approval definition.

But still thanks a lot for your response....

Sruthi17
Kilo Sage

Hi,


To add a manager approval in the workflow, all you need to do is use a approval user activity, select advanced and try the below script

Sruthi17_0-1692349440097.png

 

Please accept solution or helpful, if you find it helpful.