Users should not be able to approve their own requests

nameisnani
Mega Sage

Hello Team,

 

Can anyone suggest how to achieve this requirement?


If the approver = created by user(Requested for) then they should not be able to approve the request.

 
Please provide script and Please provide screenshots . 
 
Please provide example .
 
Thanks ,
5 REPLIES 5

Anirudh Pathak
Mega Sage

Vrushali  Kolte
Mega Sage

Hello @nameisnani ,

 

Please refer below community link for the reference -

 

https://www.servicenow.com/community/itom-forum/how-do-you-prevent-a-user-from-approving-own-request...

 

If it helps you solve the query, please mark it as Accepted✔️ and Helpful👍.

 

Jitendra Diwak1
Kilo Sage

Hi @nameisnani 

 

// Business Rule Name: PreventSelfApproval

// Table: <Name_of_the_table_where_approval_is_done>

// When to Apply: Before record insert

 

(function executeRule(current, previous /*null when async*/) {

    // Check if the requested for is the same as the approver

    if (current.requested_for == current.approver) {

        // Prevent the record from being inserted and display an error message

        gs.addErrorMessage("You cannot approve your own request.");

        return false; // Prevent the record from being inserted

    }

})(current, previous) 

 

Please accept my solution if it resolves your issue and thumps up

 

Thanks

Jitendra 

Please accept my solution if it works for and thumps up.

nameisnani
Mega Sage

Hi @Anirudh Pathak  

 

Same thing I have tried , Not worked , could you please correct one . with demo screenshot