Add a state to the state model
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 07:10 AM
Hi, I'm struggling to add a state to the change request process.
I am following this doc -
I want to add a "Completed" state between Review and Closed
I've done the following
1) From the change form, I've added the "Completed" state to the choices, giving it a value of 2.
2) Added "Completed" to the process flow
3) Created a "Complete" UI action with the following function -
function moveToCompleted(){
var ga = new GlideAjax("ChangeRequestStateHandlerAjax");
ga.addParam("sysparm_name", "getStateValue");
ga.addParam("sysparm_state_name", "completed");
ga.getXMLAnswer(function(stateValue) {
g_form.setValue("state", stateValue);
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_completed");
});
}
Now this is where I think something may be amiss
4) I've edited the script include - ChangeRequestStateHandler and added the following lines
ChangeRequestStateHandler.COMPLETED = "completed";
and further down in the script
this.STATE_NAMES["2"] = ChangeRequestStateHandler.COMPLETED;
5) I've then edited the script include - ChangeRequestStateModel_minor and added the following lines
review: {
nextState: [ "completed" ],
completed: {
moving: function() {
return this.toCompleted_moving();
},
canMove: function() {
return this.toCompleted_canMove();
}
},
},
When a (minor) change is at the review stage, I get the "Complete" button. If I click on it, the state changes to "Completed", however I get the bar along the top saying "Invalid update", and the state change is not saved.
Sorry for the lengthy post, but if anyone can give me some pointers, I'd greatly appreciate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 12:47 AM
Hi Mark,
I am no expert but thinking out loud maybe we need to add the transition in change state transitions for it to be valid. If it works out or you've found the solution please let me know. Thanks in advance !
Regards,
Dayini