Validate parent case mrvs before closing child task

IreneBest
Tera Contributor

I have a case (sn_customerservice_case) which has a child task that I don't want to close until a mrvs on the parent is not empty.

I have created a Before Update Business Rule and while this appears to validate correctly if I attempt to close the child task with an empty mrvs, it also does not recognise when the mrvs is not empty and issues an error.

The code is:

(function executeRule(current, previous /*null when async*/) {
   
    var parentCase = new GlideRecord('sn_customerservice_case'); // Adjust table name if needed
    if (parentCase.get(current.parent)) {
       
        var mrvsData = parentCase.variables.approved_quantities_backend;
       
        if (gs.nil(mrvsData) || mrvsData == '[]') {
            gs.addErrorMessage('You cannot close this task. The Approved Quantities on the Parent must be completed.');
            current.setAbortAction(true); // Aborts the save/close action
            return;
        }

    }

})(current, previous);
 
Any help would be appreciated.
0 REPLIES 0