How to stop approving RITM record

Supriya25
Tera Guru

Hi Team,

Please help me here,

when Approver try to approve RITM approvals, system has to check on RITM 'Justification' filed filled or not . is that is empty them approval operation should be aborted and set approval record back to requested . update comments on Approval record that RITM justification field is empty please fill it.

Please let me know how to achieve it on flow designer .
can we use " Do the following " ? any other ideas to fix this please 

2 REPLIES 2

Itallo Brandão
Giga Guru

Hi Supriya,

To achieve this requirement effectively, Flow Designer is not the recommended tool.

Why? Flow Designer triggers after the record has already been updated or works in parallel. If you use Flow Designer, the Approval state will first change to 'Approved', trigger the Flow, and then you would have to force it back to 'Requested'. This creates a bad user experience and messy audit logs.

The Solution: Business Rule (Before Update) To truly abort the action and provide immediate feedback to the approver, you should use a Business Rule on the Approval table. This happens before the data is saved to the database.

Here is the configuration:

  1. Table: sysapproval_approver

  2. When: Before | Update

  3. Filter Conditions: State changes to Approved AND Approval for.Task type is Requested Item

  4. Advanced Tab (Script):

(function executeRule(current, previous /*null when async*/) {

    // 1. Get the RITM Record
    var ritm = current.sysapproval.getRefRecord();

    // 2. Check if the Justification field is empty
    // Replace 'u_justification' with the exact backend name of your field on the RITM table
    if (ritm.isValidRecord() && gs.nil(ritm.u_justification)) {

        // 3. Abort the update
        // This prevents the State from changing to Approved (it stays Requested)
        current.setAbortAction(true);

        // 4. Show Error Message to the User
        gs.addErrorMessage("Approval Rejected: You cannot approve this request because the RITM 'Justification' field is empty.");
        
        // Optional: If you really need a comment logged, you can't save it with setAbortAction.
        // Instead, the error message above is the standard way to notify the user.
    }

})(current, previous);

How this works:

  1. The Approver clicks "Approve".

  2. The Business Rule runs immediately.

  3. It checks the RITM.

  4. If Justification is empty, it stops the save. The State remains Requested automatically (no need to set it back), and the user sees the error banner at the top of the screen.

If this response helps you solve the issue, please mark it as Accepted Solution.

Best regards,
Brandão.

Hi @Itallo Brandão ,

thanks for reply. how about flow which is running ? 
'Ask for Approval'
     if(state==approved")
          update RITM
 else if(state==reject)
        update RITM

what is the situation here please. will Business rule holds Flow execution & stops approvals record in requested state ?