Case should not be closed if any of the RITM is open.

Samiksha2
Mega Sage

Hi All,

 

I have a requirement when RITM is opened then no one can close or resolve the Case and when RITM is Closed then Case should Closed.

 

Samiksha2_0-1693492714287.png

Samiksha2_1-1693492743559.png

 

Please help in this. 

 

Thanks,

Samiksha

 

6 REPLIES 6

S Goutham
Tera Guru

Hey @Samiksha2 :

You can write a BR on the case table on state change to achieve this 

BR to prevent closure of Case without closing RITM:

When to run : Before Update

Condition : When State > Changes > to Close /Resolve
In Script section

Check if any Request is not closed then abort the action


Let me know if you need help in the script part

 

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

Hi @S Goutham ,

 

Please help me in the script. This would be very helpful.

 

Thanks,

Samiksha

@Samiksha2 Please find the below screenshot and the code snippet

SGoutham_0-1693544491370.pngSGoutham_1-1693544515641.png

 

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

    function CheckActiveRequest() {
        try {
            var activereq = [];
            var case_rel_req = new GlideRecord('sc_request');
            case_rel_req.addQuery('parent', current.sys_id.toString());
            case_rel_req.query();
            while (case_rel_req.next()) {
                if (case_rel_req.state == 'in_process' || case_rel_req.state == 'requested') { // Active State of Request
                    activereq.push(case_rel_req.number.toString());
                }
            }
            if (activereq.length > 1) { // If we find any active request
                gs.addErrorMessage('There are still active request ' + activereq + ' close those to close the case');
                current.setAbortAction(true); // abort the closure of case
            }
        } catch (e) {
            gs.info('Error in BR [Dont Allow Case Clousre] ' + e);
        }
    }

})(current, previous);

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

Hi @S Goutham ,

 

Thank you for your help. But still I can close the case if RITM or Request is active.