Close Release Task warning before closing Release Record

Mayur Patil2
Tera Expert

Hello developers,

 

I have one requirement where Release Task should be close before closing Release Record. If the Release task in not in any one of the closed state, i.e. Closed complete, closed incomplete, closed skipped then Release record should not get close and it should show an error message.

Please let me know how can I achieve this.

 

Thank you

1 REPLY 1

Mayur Patil2
Tera Expert

Just want to highlight I am currently using below BR. but here error msg is coming but state is in close state. And if I reload form then it come backs to previous state. Sharing SS for reference.

 

(function executeRule(current, previous /*null when async*/) {
 
    // Query all release tasks related to the current release
    var taskGr = new GlideRecord('release_task');
    taskGr.addQuery('release', current.sys_id);
    taskGr.query();
 
    // Check if any release task is still open
    var openTasks = false;
    while (taskGr.next()) {
        if (taskGr.state != 'closed complete' , 'closed incomplete' , 'closed skipped') {
            openTasks = true;
            break;
        }
    }
 
    // If any tasks are open, prevent closing the release and display an error message
    if (openTasks && current.state == 'closed complete' , 'closed incomplete' , 'closed skipped') {
        current.setAbortAction(true);
        current.setReturn('Operation not permitted: Close all release tasks before closing the release.');
        gs.addErrorMessage('Operation not permitted: Close all release tasks before closing the release.');
    }
 
})(current, previous);
 
MayurPatil2_0-1715836633570.png

 

Please correct me in this BR code so that state should not move to close state if task are open.

 

Thank you