how to make a field mandatory after it goes for approval

Matt J Thomas
Tera Contributor

I have a request where when a manager approves a change request, a mandatory field must be filled out by the manager. I have no idea on how to do that. I can set the field to mandatory at any other stage but how can I make it so that once the manager approves the request, they must enter a value in the field. Many Thanks in advance for your feedback.

6 REPLIES 6

Hi @Matt J Thomas 

Upon thorough review of your use case, I've identified potential gaps that may be overlooked if we rely solely on the onsubmit client script.

Let's do the server-side validation with a before business rule instead.

Sample below.

TaiVu_1-1699891494301.png

 

(function executeRule(current, previous /*null when async*/ ) {
	
    if (gs.nil(current.sysapproval.ref_change_request.u_scheduled_for_release)) {
        current.setAbortAction(true);
        gs.addErrorMessage('Please enter the "Scheduled for Release" field in Change Request before giving your approval');
    }

})(current, previous);

 

 

Don't forget to test it.

Screenshot 2023-11-13 at 23.05.20.png

Screenshot 2023-11-13 at 23.07.08.png

 

Cheers,

Tai Vu

 

 

ChiranjeeviR
Kilo Sage

Hi @Matt J Thomas , 

You can use UI Policy with a condition approval is requested and you can make field mandatory.

or

You can define what level approval you want to use mandatory field,so you can give condition that when it is requested field should be mandatory through script in work flow logic.

 

Thankyou,
Chiranjeevi R

Mark my answer Helpful & Accepted if I have answered your question

Thanks & Regards,
Chiranjeevi
ServiceNow Developer | | ITSM | | ServiceNow Discovery | | Event Management | | Service Mapping | | CMDB

Please mark as Correct Answer/Helpful, if applicable.