Unable to revert to review from close state

Hermes14
Tera Contributor

Hi,

I've added approvals in the Review state for change management. I created a business rule so that when attempting to close a change request while approvals are still pending, an error message appears, and the state should revert from Closed back to Review. However, the window does not automatically reload, and the change request remains in the Closed state until manually refreshed. Any solutions on how to fix this?
This is the BR I created

 var approve = new GlideRecord('sysapproval_approver');
    approve.addQuery('document_id', current.sys_id);
    approve.addQuery('state', 'requested');
    approve.query();

    if (approve.hasNext()) {
        gs.addErrorMessage("Approvals are still pending");
        current.setAbortAction(true);
        current.state = previous.state;
        gs.setRedirect(current);
    }

Thanks in advance for your help!

3 REPLIES 3

shantanu_patel8
Mega Guru

Hi @Hermes14 ,

 

Since you are expecting the change to happen on real time. The ideal way would be use a onSubmit/onChange client script to achieve this functionality .

 

You can configure the client script to check for any pending approvals before the state is changed to closed. I can also suggest you to use the display business rule to check for the approvals so that you don't have to use GlideAjax.

 

Please mark the answer helpful and correct if it resolves the issue. Happy scripting 

shantanu_patel8_0-1747282106914.png

 

 

-Shantanu

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Hermes14 

 

I think you need to add this to approval policies so that it can be easily managed.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Mark Manders
Mega Patron

How are they closing the Change? If it's a UI action, just don't make it visible when approvals are pending. If it's the state field, hide the option 'close' if approvals are pending.

Or use a 'before' business rule that aborts the action when the Change closes and there still are approvals pending. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark