Is there a way we can prevent users from closing a Problem unless it is approved by the Group Manager?perhaps through a role, a business rule?

nomemon
Kilo Contributor

Is there a way we can prevent users from closing a Problem unless it is approved by the Group Manager?perhaps through a role, a business rule?

1 ACCEPTED SOLUTION

Thanks for the update.


You have to create a before business rule on problem table and have filter condition to execute when problem state is change to closed (So that the BR is fired only in this case).


Script :


var grpManager = current.assignment_group.manager;


var gr = new GlideRecord('sysapproval_approver');


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


gr.addQuery('approver', grpManager);


gr.addQuery('state', 'approved');


gr.query();


if(!gr.next())


  {


  gs.addErrorMessage('YOUR MESSAGE');


  current.setAbortAction(true);


  }


View solution in original post

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Noman,



You mean approvals are triggered for the prb? Is there any field you have which sets to approved?


THanks Pradeep.


The issue is that users aren't waiting for the problem to be approved before they close it.


Although yes, approvals are triggered, but if they're not approved on time, then users with the problem management role approve them (even though they're not approvers themselves, but assigned to those problems).


Hope this helps



Nomaan


Thanks for the update.


You have to create a before business rule on problem table and have filter condition to execute when problem state is change to closed (So that the BR is fired only in this case).


Script :


var grpManager = current.assignment_group.manager;


var gr = new GlideRecord('sysapproval_approver');


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


gr.addQuery('approver', grpManager);


gr.addQuery('state', 'approved');


gr.query();


if(!gr.next())


  {


  gs.addErrorMessage('YOUR MESSAGE');


  current.setAbortAction(true);


  }


Kalaiarasan Pus
Giga Sage

I have a simple suggestion. Why show the button or the action if the user is not allowed to act on it?



If the user is not allowed to close before approval, dont show the button. Have the above check on the button rather than a business rule