Change management

P1234
Tera Contributor

If the past event is informational  we will display cancel button only for CM team(SSC) when CM member cancel the event will be cancelled , no relationship with change.

 

if the past event is non-information we will also display cancel button only for CM team(SSC) but here we have another logic if the associate change already in progress or further  , cancel button is hidden for everyone if the associate change still in WTD or before we will display the cancel button only for CM team.

 

Any idea how to build please let me know

2 REPLIES 2

Mark Manders
Mega Patron

What do you mean with 'event'? How is it related to the change? Is the change a field on the form? Then you can dotwalk to it through your UI action condition.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Yes i build the code but not working

 

1.UI Action : Cancel Button

// [UI Action Script: Cancel Button]
var userGR = new GlideRecord('sys_user');
userGR.get(gs.getUserID());

var userInCMTeam = new GlideRecord('sys_user_grmember');
userInCMTeam.addQuery('user', gs.getUserID());
userInCMTeam.addQuery('group.name', 'SSC');
userInCMTeam.query();

if (!userInCMTeam.hasNext()) {
answer = false; // User is not part of CM team
} else {
var changeGR = new GlideRecord('change_request');
if (current.change_request && changeGR.get(current.change_request)) {
if (current.informational == true) {
answer = true;
} else {
var status = changeGR.state.name.toLowerCase();
if (status == 'in progress' || status == 'implemented' || status ==…
2.Business Rules

// [Business Rule: After - Triggered by 'Cancel' button]
if (current.u_cancel_requested) {
current.state = 'Cancelled'; // Or appropriate canceled state
current.u_relationship_to_change = ''; // Clear link to change
current.update();
}
3. Script Include : Server side to Client side calling
var CheckCMTeamMembership = Class.create();
CheckCMTeamMembership.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isCMTeamMember: function() {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', gs.getUserID());
gr.addQuery('group.name', 'SS');
gr.query();
return gr.hasNext();
}
});
Client Side Code (Onload)(function executeRule(current, gForm, gUser, gSNC) {
// Fetch user groups
return new GlideAjax('CheckCMTeamMembership').getAnswer();
})();