File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ //Prevent Rejection Without Comments
2+ function onSubmit ( ) {
3+ // Get the current state value of the approval record
4+ var state = g_form . getValue ( 'state' ) ;
5+
6+ // Get the comments entered by the approver
7+ var comments = g_form . getValue ( 'comments' ) ;
8+
9+ // Check if the approver is trying to REJECT the record
10+ // The out-of-box (OOB) value for rejection in sysapproval_approver is "rejected"
11+ // If state is 'rejected' and comments are empty, stop the submission
12+ if ( state == 'rejected' && ! comments ) {
13+
14+ // Display an error message to the user
15+ g_form . addErrorMessage ( 'Please provide comments before rejecting the approval.' ) ;
16+
17+ // Prevent the form from being submitted (block save/update)
18+ return false ;
19+ }
20+
21+ // Allow the form submission if validation passes
22+ return true ;
23+ }
You can’t perform that action at this time.
0 commit comments