Skip to content

Commit dc4bb9c

Browse files
authored
Create script.js
1 parent 5cab778 commit dc4bb9c

File tree

1 file changed

+23
-0
lines changed
  • Client-Side Components/Client Scripts/Prevent Rejection Without Comments

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}

0 commit comments

Comments
 (0)