how to make a field mandatory after it goes for approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2023 08:49 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2023 08:07 AM - edited ‎11-13-2023 08:08 AM
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.
(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.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2023 11:36 PM
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
Chiranjeevi
ServiceNow Developer | | ITSM | | ServiceNow Discovery | | Event Management | | Service Mapping | | CMDB
Please mark as Correct Answer/Helpful, if applicable.