- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 10:45 AM
I am trying to have the change be set to a state of Cancelled when it is in one of the following states:
- New
- Assess
- Authorize
- Scheduled
- Implement
If the change advances to a state of Review, I don't want to be able to cancel the change. I am using a copy of the OOTB UI Action and it allows you to cancel at any state but closed.
I've tried adding to the Condition field the following phrases (in red) and none of them appear to work. What am I doing wrong????
Condition: gs.hasRole('itil') && new ChangeRequestStateHandler(current).canMoveTo("canceled")&¤t.state!=0
- This did NOT allow the change to cancel, but it did hide the button from appearing when the state = Review (which is also what I want)
Condition: gs.hasRole('itil') && new ChangeRequestStateHandler(current).canMoveTo("canceled") && ChangeRequestStateHandler(current).isNOT("review")
- This didn't allow the change button to appear on the form at all, nor did it allow to cancel
__________________________________________________________________________________________
UI Action Script:
var changeConfirmCancelDialog;
function loadConfirmDialog() {
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
changeConfirmCancelDialog = new dialogClass("change_confirm_cancel", false, 648, 250);
changeConfirmCancelDialog.setTitle(new GwtMessage().getMessage("Cancel Change Request"));
changeConfirmCancelDialog.render();
}
function moveToCancel(notes) {
var ga = new GlideAjax("ChangeRequestStateHandlerAjax");
ga.addParam("sysparm_name", "getStateValue");
ga.addParam("sysparm_state_name", "canceled");
ga.getXMLAnswer(function(stateValue) {
g_form.setValue("state", stateValue);
g_form.setValue("work_notes", notes);
changeConfirmCancelDialog.destroy();
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_canceled");
});
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 02:46 PM
Hi Shane,
BIG OLE FACE PALM!!!! :(. The one thing I didn't try. I left it there because it was OOTB and assumed it was needed. After removing it per your suggestion and then adding in a condition of show when current.state=XYZ it worked!
Thanks for pointing out something so obvious. I had my blinders up :/.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 02:04 PM
What benefit are you getting from keeping this in there?
&& new ChangeRequestStateHandler(current).canMoveTo("canceled")
I'd probably start with removing that and working up to it (if it's even needed).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 02:46 PM
Hi Shane,
BIG OLE FACE PALM!!!! :(. The one thing I didn't try. I left it there because it was OOTB and assumed it was needed. After removing it per your suggestion and then adding in a condition of show when current.state=XYZ it worked!
Thanks for pointing out something so obvious. I had my blinders up :/.