CHANGE MANAGEMENT : Any state to cancelled

JulietD
Mega Guru

Hi,

 

My question is, As a member of the assigned change management group of the service offering, I want to be able to cancel the Change at any stage (not closed), so that if it was raised in error, the process can continue. - Agree on which method to use to move to the canceled state – note that whatever method has been used before should be the same here for a consistent user experience.

 

My Workaround,

Created a new UI action with condition and script as below,

condition: 

current.state != '3' && gs.hasRole('change_manager') && gs.getUser().isMemberOf(''+current.assignment_group);

 script:

(function executeCancelChange() {
    var gr = new GlideRecord('sys_user_grmember');
    gr.addQuery('group', current.assignment_group);
    gr.addQuery('user', gs.getUserID());
    gr.query();
   
    if (gr.next()) {
        current.state = '4'; // Replace 'cancelled' with the actual state value if different
        gs.addInfoMessage('The change request has been cancelled.');
current.update();
    } else {
        gs.addErrorMessage('You are not a member of the assigned change management group.');
    }
})();
 
Is this the correct workaround? 
Any better workaround than this? 
 
Thank you
 
1 REPLY 1

Bert_c1
Kilo Patron

Seems you are using server-side code in a client-side script. I use 'alert()' in those to display info the user has to acknowledge. Look at UI actions that use GlideAjax in the script to run server-side code and get a result.