force comment on change request rejection

RBlor
Mega Guru

I have set up the business rule to force comment on change request rejection but it  does not seem to work:

 

  1. Create a Business Rule:

    • Navigate to System Definition > Business Rules.

    • Click New to create a new Business Rule.

    • Fill out the following fields:

      • Name: Require Comments on Change Approval Rejection

      • Table: Approval [sysapproval_approver]

      • Advanced: Check this option to enable scripting.

      • When: Before Update

      • Order: (You can leave it as default unless there are other Business Rules that might conflict.)

      • Condition: Leave blank; we'll use scripting to define the condition.

  2. Script:

     

 

 

 

 

// Only proceed if state is changing to 'rejected'
if (current.state.changesTo('rejected')) {
    // Check if the approval is for a Change Request
    var sysapprovalGr = current.sysapproval.getRefRecord();
    if (sysapprovalGr.getTableName() == 'change_request') {
        // Enforce that Comments are provided
        if (gs.nil(current.comments)) { // Replace 'comments' with the actual field name if different
            gs.addErrorMessage('Please provide a comment before rejecting the approval.');
            current.setAbortAction(true); // Prevents the record from being saved
        }
    }
}

 

 

 

 

3 REPLIES 3

Najmuddin Mohd
Mega Sage

Hi @RBlor ,

There is already an OOB UI Policy which makes comments mandatory when state changes to Rejected.
Name: Comments mandatory on rejection.

NajmuddinMohd_0-1728107530677.png


If the above information helps you, Kindly mark it as Helpful and Accept the solution.

Regards,
Najmuddin.

davidburnerr
Giga Contributor

Hey @RBlor, you could use a combination of both UI policy and business rules to ensure everything works properly. Have you checked if the UI policy Najmuddin mentioned is active on your form? Perhaps considering portable restroom rental for larger events or outdoor gatherings could also be beneficial.

this is active but change managers can right click and approve on the approvers tab related list on the change request.