Policy Exception Approval Rejections to be routed back to REVIEW state

ShafrazMubarak
Giga Guru
 
2 REPLIES 2

ShafrazMubarak
Giga Guru

Once a policy exception approvals (which is generated after the review state) is rejected/requested more info, It is routing back to the requester of the policy exception. We need this to come back to review state and assign to the group who actually raised the approval from the review state. 

 

How we can do this?

Satishkumar B
Giga Sage
Giga Sage

Hi @ShafrazMubarak 

To route a rejected or more info requested policy exception back to the review state and reassign it:

  1. Create a Business Rule on the Policy Exception table.
  2. Script: When state is Rejected or Requested for More Information, set current.state to Review and assign it to the group that raised the initial approval.

 

 

// Function to get the initial approver group
function getInitialApproverGroup(recordId) {
    var gr = new GlideRecord('your_approval_table'); // Replace with your table
    gr.addQuery('policy_exception', recordId); // Adjust query based on your data structure
    gr.query();

    if (gr.next()) {
        return gr.assignment_group; // Adjust field name as necessary
    }

    return ''; // Default or handle as needed
}

// Business Rule Script
(function executeRule(current, previous) {
    if (current.state == 'Rejected' || current.state == 'Requested for More Information') {
        current.state = 'Review'; // Ensure this is the correct review state value
        current.assignment_group = getInitialApproverGroup(current.sys_id);
        current.update();
    }
})(current, previous);

 

 

 

…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution !! If this helps you to understand.

…………………………………………........................................................................................