stop Change Request being approved by the person who created it

Community Alums
Not applicable

hi all,

we have a requirement to stop  stop Change Request being approved by the person who created it. for this i have created a business rule. but unfortunately its not stopping for approve. please see below.

i write before update business and see code below

var gr = new GlideRecord('sysapproval_approver');


gr.setWorkflow(false);


gr.addQuery('sysapproval', current.sys_id);


gr.addQuery('state','!=','cancelled');


gr.query();


var foundUser = false;


while (gr.next()){


if (gr.approver == current.requested_by){


gr.setValue('state', 'cancelled');


gr.comments = 'Requested by user not allowed to be an approver';


gr.update();


foundUser = true;


}


if (foundUser)


gs.addErrorMessage("Requested by user " + current.requested_by.getDisplayValue() + " is not allowed to be an approver of this Change Request.");


}

 

But this not working as expected.

the change request shows cancelled but its not asking further approvals

YekkalaSivaSa_0-1671527782528.png

 and see approval tab 

 

YekkalaSivaSa_1-1671527811959.png

 your response is much appreciated, Thanks.

 

 

3 REPLIES 3

jaheerhattiwale
Mega Sage
Mega Sage

@Community Alums I would suggest not to send the approval to the created by user. That should solve the issue.

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Community Alums
Not applicable

hi jaheer,

 

the approvals will trigger automatically based on the assignment group, so if the opened by user is part of that particular group it will trigger automatic. 

@Community Alums You can check below thread. Solved question.

 

https://www.servicenow.com/community/it-service-management-forum/change-prevent-requester-from-approving/m-p/606315#M178094

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023