Which script controls on-hold, off-hold behavior for change requests (approvals)?

Joseph Warner
Tera Guru

When I check the "On hold" checkbox in a change request it places the change on hold. When I un-check this "On hold" checkbox and save, it removes the hold then resets the approvals. What script controls the behavior of resetting the approvals?

 

I need to override this behavior so that the existing approvals are not affected.

JosephWarner_0-1681399882578.png

 

1 ACCEPTED SOLUTION

If you need to override this behavior and keep the existing approvals intact, you can write a script that prevents the system from resetting the approvals when the "On hold" checkbox is unchecked. To do this, you can create a Before Business Rule on the Change Request table, and add the following script:

 

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

// Check if the "On hold" checkbox is being unchecked
if (current.on_hold.changes() && !current.on_hold) {

// Get the current state of the approvals
var approvals = current.approvals.getDisplayValue();

// Set the "On hold" checkbox back to checked
current.on_hold = true;

// Update the change request record
current.update();

// Restore the state of the approvals
current.approvals = approvals;

}

})(current, previous);

 

View solution in original post

7 REPLIES 7

Ian Mildon
Tera Guru

On our instances this function is performed by a workflow. I know this as I recently edited such a workflow to improve the approval reset portion for the "second" level of approvals we utilize.

 

Take a look at your instance's Workflows for the Change Request table

Chaitanya Redd1
Tera Guru

When the "On hold" checkbox is unchecked in a change request, it triggers a Business Rule called Change Request: On Hold. This Business Rule contains the script that controls the behaviour of resetting the approvals. To override this behaviour and prevent the existing approvals from being affected, you can create a new Business Rule that runs after the Change Request: On Hold Business Rule and updates the approvals.

Is that an OOB Business Rule? On checking my instances I do not see any such BR listed. Not saying that it isn't but if that's something that was skipped due to customizations, I'd be curious on checking it out and getting it included.

If you need to override this behavior and keep the existing approvals intact, you can write a script that prevents the system from resetting the approvals when the "On hold" checkbox is unchecked. To do this, you can create a Before Business Rule on the Change Request table, and add the following script:

 

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

// Check if the "On hold" checkbox is being unchecked
if (current.on_hold.changes() && !current.on_hold) {

// Get the current state of the approvals
var approvals = current.approvals.getDisplayValue();

// Set the "On hold" checkbox back to checked
current.on_hold = true;

// Update the change request record
current.update();

// Restore the state of the approvals
current.approvals = approvals;

}

})(current, previous);