If "Requested for " and same requested for if member of the group approval

nameisnani
Mega Sage

Hi Team , 

 

can any one please help me in this requriemnt .

 

If "Requested for "  and same requested for if member of the group approval of the same catalog then requested for user shouldn't be able approve the request instead it should abort with some error message. 

 

Please provide correct script or BR or Flow steps to achieve this snieriao , i have already pasted in communtiy , not working , 

 

can any one please provide correct scirpt . with testing results with screenshots for better understanding ,

 

NOTE - our requirment is 

 

If "Requested for "  and same requested for if member of the group approval of the same catalog then requested for user shouldn't be able approve the request instead it should abort with some error message. 

 

Please provide configuration screenshots .

7 REPLIES 7

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

    // Add your code here
    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("sys_id", current.sysapproval);
	gr.addQuery("cat_item.name", "Your Catalog Item Name");
    gr.addQuery("request.requested_for", current.approver);
    gr.query();
    if (gr.hasNext()) {
        gs.info("Approver is same as requested for");
        current.setAbortAction(true);
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

nameisnani
Mega Sage

Hi @Ankur Bawiskar 

 

It is not for particular catalog , it is for appover table.

@nameisnani 

the BR will be on approver table

Did you check the script I shared and enhance it?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader