Creating New Change Type > Adding new states

Brendan Hallida
Kilo Guru

Hi all,

I created a new change type (minor) using this tutorial, and then used this tutorial to add my own states.

The States I have added for this test is:

  1. Develop and Implement in UAT (8)
  2. Test in UAT (12)

 

The issue I am having is that when I go to the change, When it is at New, the new state of 'Develop and Implement in UAT' is not available.

It is probably worth noting that the change request here was heavily modified by the implementer, and the OOB states (Draft, Assess etc) have been removed as part of the implementation before my time.

Below are the two script includes edited as per the tutorial.  Any clues where I am going wrong?

Thanks in Advance!

ChangeRequestStateHandler

var ChangeRequestStateHandler = Class.create();

// All references to statehandler constants should be through this class ChangeRequestStateHandler
ChangeRequestStateHandler.DRAFT = ChangeRequestStateHandlerSNC.DRAFT;
ChangeRequestStateHandler.ASSESS = ChangeRequestStateHandlerSNC.ASSESS;
ChangeRequestStateHandler.AUTHORIZE = ChangeRequestStateHandlerSNC.AUTHORIZE;
ChangeRequestStateHandler.SCHEDULED = ChangeRequestStateHandlerSNC.SCHEDULED;
ChangeRequestStateHandler.IMPLEMENT = ChangeRequestStateHandlerSNC.IMPLEMENT;
ChangeRequestStateHandler.REVIEW = ChangeRequestStateHandlerSNC.REVIEW;
ChangeRequestStateHandler.CLOSED = ChangeRequestStateHandlerSNC.CLOSED;
ChangeRequestStateHandler.CANCELED = ChangeRequestStateHandlerSNC.CANCELED;
ChangeRequestStateHandler.DEVELOP_AND_IMPLEMENT_IN_UAT = "develop_and_implement_in_uat";
ChangeRequestStateHandler.TEST_IN_UAT = "test_in_uat";

ChangeRequestStateHandler.prototype = Object.extendsObject(ChangeRequestStateHandlerSNC, {
	MINOR:"minorv2",
	initialize: function(changeRequestGr) {
		ChangeRequestStateHandlerSNC.prototype.initialize.call(this, changeRequestGr);
		this.STATE_NAMES["8"] = ChangeRequestStateHandler.DEVELOP_AND_IMPLEMENT_IN_UAT;
		this.STATE_NAMES["12"] = ChangeRequestStateHandler.TEST_IN_UAT;
	},
	_resetModel: function() {
		this._model = null;
		var type = this._gr.getValue('type') + "";
		
		if (type == this.NORMAL || type == this.STANDARD || type == this.EMERGENCY)
			ChangeRequestStateHandlerSNC.prototype._resetModel.call(this);
		else if (type == this.MINOR)
			this._model = new ChangeRequestStateModel_minor(this._gr);
	},
	type: "ChangeRequestStateHandler"
});

ChangeRequestStateModel_minor 

var ChangeRequestStateModel_minor = Class.create();
ChangeRequestStateModel_normal.prototype = Object.extendsObject(ChangeRequestStateModelCust_minor, {
	draft: {
		nextState: [ "develop_and_implement_in_uat" ],
		
		develop_and_implement_in_uat: {
			moving: function() {
				return this.toDevelopuat_moving();
			},
			
			canMove: function() {
				return this.toDevelopuat_canMove();
			}
		},
		
		canceled: {
			moving: function() {
				return this.toCanceled_moving();
			},
			
			canMove: function() {
				return this.toCanceled_canMove();
			}
		}
	},
	
	develop_and_implement_in_uat: {
		nextState: [ "test_in_uat" ],
		
		test_in_uat: {
			moving: function() {
				return this.toTestuat_moving();
			},
			
			canMove: function() {
				return this.toTestuat_canMove();
			}
		},
		
		canceled: {
			moving: function() {
				return this.toCanceled_moving();
			},
			
			canMove: function() {
				return this.toCanceled_canMove();
			}
		}
	},
	
	authorize: {
		nextState: [ "scheduled" ],
		
		draft: {
			moving: function() {
				return this.toDraft_moving();
			},
			
			canMove: function() {
				return this.toDraft_canMove();
			}
		},
		
		scheduled: {
			moving: function() {
				return this.toScheduled_moving();
			},
			
			canMove: function() {
				return this.toScheduled_canMove();
			}
		},
		
		canceled: {
			moving: function() {
				return this.toCanceled_moving();
			},
			
			canMove: function() {
				return this.toCanceled_canMove();
			}
		}
	},
	
	scheduled: {
		nextState: [ "implement" ],
		
		implement: {
			moving: function() {
				return this.toImplement_moving();
			},
			canMove: function() {
				return this.toImplement_canMove();
			}
		},
		
		canceled: {
			moving: function() {
				return this.toCanceled_moving();
			},
			
			canMove: function() {
				return this.toCanceled_canMove();
			}
		}
	},
	
	implement: {
		nextState: [ "review" ],
		
		review: {
			moving: function() {
				return this.toReview_moving();
			},
			
			canMove: function() {
				return this.toReview_canMove();
			}
		},
		
		canceled: {
			moving: function() {
				return this.toCanceled_moving();
			},
			
			canMove: function() {
				return this.toCanceled_canMove();
			}
		}
	},
	
	review: {
		nextState: [ "closed" ],
		
		closed: {
			moving: function() {
				return this.toClosed_moving();
			},
			
			canMove: function() {
				return this.toClosed_canMove();
			}
		},
		
		canceled: {
			moving: function() {
				return this.toCanceled_moving();
			},
			
			canMove: function() {
				return this.toCanceled_canMove();
			}
		}
	},
	
	closed: {},
		
		canceled: {},
			
			toDevelopuat_moving: function() {
				return true;
			},
			
			toDevelopuat_canMove: function() {
				return true;
			},
			
			toTestuat_moving: function() {
				return true;
			},
			
			toTestuat_canMove: function() {
				return true;
			},
			
			type: "ChangeRequestStateModel_minor"
		});

 

 

 

 

1 ACCEPTED SOLUTION

You can try to add new STATE_NAMES on ChangeRequestStateHandler  

this.STATE_NAMES["1"] = ChangeRequestStateHandler.DRAFT;

Then try again. 

 

View solution in original post

31 REPLIES 31

Hey mate, please dont apologise, I am grateful for the help!

 

The message appears after putting that info message in.

 

I will test with a new one, I just wonder if the customisation done during implementation is causing the issue here.  For example, the default OOB states have been deleted (assess, authorize etc).  The change form is currently running with next steps and status flows.

Wanted to get it back closer to OOB, but damn it is really convoluted to do so.

 

Which script include do you think the issue lies?

 

Thanks again for your help mate

I am not sure yet. Do you also see any of the below log in system log?

 

find_real_file.png

 

I have a strong feeling, you will have to modify this script and add your states, because the function getNextStates can't find you state here. This is the same function called from the business rule where we added gs.addInfoMessage()

find_real_file.png


Please mark this response as correct or helpful if it assisted you with your question.

Hey,

There is no logs for in the system for that debug found in ChangeRequestStateHandlerSNC.

I am pretty sure that ChangeRequestStateHandler extends ChangeRequestStateHandlerSNC and I have added the states in there.  the SNC version is read only also.

I have done all of this in a personal dev instance, and it works fine, but that has all the base states etc and has not been previously configured. 

I just cannot see the states not existing being an issue.

Here is my ChangeRequestStateHandler

var ChangeRequestStateHandler = Class.create();

// All references to statehandler constants should be through this class ChangeRequestStateHandler
ChangeRequestStateHandler.DRAFT = ChangeRequestStateHandlerSNC.DRAFT;
ChangeRequestStateHandler.ASSESS = ChangeRequestStateHandlerSNC.ASSESS;
ChangeRequestStateHandler.AUTHORIZE = ChangeRequestStateHandlerSNC.AUTHORIZE;
ChangeRequestStateHandler.SCHEDULED = ChangeRequestStateHandlerSNC.SCHEDULED;
ChangeRequestStateHandler.IMPLEMENT = ChangeRequestStateHandlerSNC.IMPLEMENT;
ChangeRequestStateHandler.REVIEW = ChangeRequestStateHandlerSNC.REVIEW;
ChangeRequestStateHandler.CLOSED = ChangeRequestStateHandlerSNC.CLOSED;
ChangeRequestStateHandler.CANCELED = ChangeRequestStateHandlerSNC.CANCELED;
ChangeRequestStateHandler.DEVELOP_AND_IMPLEMENT_IN_UAT = "develop_and_implement_in_uat";
ChangeRequestStateHandler.TEST_IN_UAT = "test_in_uat";

ChangeRequestStateHandler.prototype = Object.extendsObject(ChangeRequestStateHandlerSNC, {
	MINOR:"minorv2",
	initialize: function(changeRequestGr) {
		ChangeRequestStateHandlerSNC.prototype.initialize.call(this, changeRequestGr);
		this.STATE_NAMES["8"] = ChangeRequestStateHandler.DEVELOP_AND_IMPLEMENT_IN_UAT;
		this.STATE_NAMES["12"] = ChangeRequestStateHandler.TEST_IN_UAT;
	},
	_resetModel: function() {
		this._model = null;
		var type = this._gr.getValue('type') + "";
		gs.log('++++++++type is+++++++'+type);
		
		if (type == this.NORMAL || type == this.STANDARD || type == this.EMERGENCY)
			ChangeRequestStateHandlerSNC.prototype._resetModel.call(this);
		else if (type == this.MINOR)
			this._model = new ChangeRequestStateModel_minor(this._gr);
		else if (type == this.EXPEDITED) 
                this._model = new ChangeRequestStateModel_expedited(this._gr); 
	},
	type: "ChangeRequestStateHandler"
});

Ok.. One more debug statements. This should clear it is an issue with ChangeRequestStateModel_minor

 

var ChangeRequestStateHandler = Class.create();

// All references to statehandler constants should be through this class ChangeRequestStateHandler
ChangeRequestStateHandler.DRAFT = ChangeRequestStateHandlerSNC.DRAFT;
ChangeRequestStateHandler.ASSESS = ChangeRequestStateHandlerSNC.ASSESS;
ChangeRequestStateHandler.AUTHORIZE = ChangeRequestStateHandlerSNC.AUTHORIZE;
ChangeRequestStateHandler.SCHEDULED = ChangeRequestStateHandlerSNC.SCHEDULED;
ChangeRequestStateHandler.IMPLEMENT = ChangeRequestStateHandlerSNC.IMPLEMENT;
ChangeRequestStateHandler.REVIEW = ChangeRequestStateHandlerSNC.REVIEW;
ChangeRequestStateHandler.CLOSED = ChangeRequestStateHandlerSNC.CLOSED;
ChangeRequestStateHandler.CANCELED = ChangeRequestStateHandlerSNC.CANCELED;
ChangeRequestStateHandler.DEVELOP_AND_IMPLEMENT_IN_UAT = "develop_and_implement_in_uat";
ChangeRequestStateHandler.TEST_IN_UAT = "test_in_uat";

ChangeRequestStateHandler.prototype = Object.extendsObject(ChangeRequestStateHandlerSNC, {
	MINOR:"minorv2",
	initialize: function(changeRequestGr) {
		ChangeRequestStateHandlerSNC.prototype.initialize.call(this, changeRequestGr);
		this.STATE_NAMES["8"] = ChangeRequestStateHandler.DEVELOP_AND_IMPLEMENT_IN_UAT;
		this.STATE_NAMES["12"] = ChangeRequestStateHandler.TEST_IN_UAT;
	},
	_resetModel: function() {
		this._model = null;
		var type = this._gr.getValue('type') + "";
		
		if (type == this.NORMAL || type == this.STANDARD || type == this.EMERGENCY)
			ChangeRequestStateHandlerSNC.prototype._resetModel.call(this);
		else if (type == this.MINOR)
{
gs.log('Inside Else If');
			this._model = new ChangeRequestStateModel_minor(this._gr);
gs.log('Next State for Draft is '+this._model['draft']);
}
	},
	type: "ChangeRequestStateHandler"
});

Please mark this response as correct or helpful if it assisted you with your question.

Hey,

 

Here are the logs from that.  strange how it says object: object

 

find_real_file.png