Adding New Change Type

Brian Lancaster
Tera Sage

I followed this document to add a new change type.  However it does not go over how to update the ChangeRequest script include so you can create a change request of this new type thought a UI Action.  How do I go updating the script include?

17 REPLIES 17

Tony K
Kilo Sage
Kilo Sage

Hi Brian,

I also added a new change type and there were some steps that are not covered in the docs site when it came to updating the workflows and script includes. See if the below makes any sense. 

 

You need to edit a script include called "ChangeRequest" to account for your new change type. The new type in this example is called Expedited. I hope this helps anyone who adds new change types in the future. 

 

var ChangeRequest = Class.create();

ChangeRequest.NORMAL = "normal";
ChangeRequest.STANDARD = "standard";
ChangeRequest.EMERGENCY = "emergency";
ChangeRequest.EXPEDITED = "expedited"; //Change this to match your change type
ChangeRequest.CHANGE_REQUEST = "change_request";

ChangeRequest.prototype = Object.extendsObject(ChangeRequestSNC, {
EXPEDITED_WORKFLOW: "Change Request - Expedited", //Change this to match your change type workflow

newExpedited : function(Expedited) { //Update the name of this
return ChangeRequestSNC.newChange(ChangeRequest.EXPEDITED); //Update this to match the variable name from above
},

_getWorkflowFromType: function(type){
var workflow = "";
switch (type){
case ChangeRequest.EMERGENCY:
workflow = this.EMERGENCY_WORKFLOW;
break;
case ChangeRequest.NORMAL:
workflow = this.NORMAL_WORKFLOW;
break;
case ChangeRequest.STANDARD:
workflow = this.STANDARD_WORKFLOW;
break;
case ChangeRequest.EXPEDITED://CHANGE TO MATCH YOUR TYPE
workflow = this.EXPEDITED_WORKFLOW;//CHANGE TO MATCH YOUR WORKFLOW DECLARATION
break;
}
return workflow;
},



type: "ChangeRequest"
});

ChangeRequest.newNormal = ChangeRequestSNC.newNormal;

ChangeRequest.newStandard = ChangeRequestSNC.newStandard;

ChangeRequest.newEmergency = ChangeRequestSNC.newEmergency;

ChangeRequest.newExpedited = ChangeRequestSNC.newExpedited;//Update this to match what you called the function above

ChangeRequest.newChange = ChangeRequestSNC.newChange;

I updated the code but it is still not working.  we use the Change Request - Normal workflow for this, so that is why you will see that in my code.  Did I miss something else?  When I try the UI Action I get Expedite Change undefined created from...

 

var ChangeRequest = Class.create();

ChangeRequest.NORMAL = "normal";
ChangeRequest.STANDARD = "standard";
ChangeRequest.EMERGENCY = "emergency";
ChangeRequest.EXPEDITE = "expedite"; //Change this to match your change type
ChangeRequest.CHANGE_REQUEST = "change_request";

ChangeRequest.prototype = Object.extendsObject(ChangeRequestSNC, {
	EXPEDITE_WORKFLOW: "Change Request - Normal", //Change this to match your change type workflow
	
	newExpedite : function(Expedite) { //Update the name of this
		return ChangeRequestSNC.newChange(ChangeRequest.EXPEDITE); //Update this to match the variable name from above
	},
	
	_getWorkflowFromType: function(type){
		var workflow = "";
		switch (type){
			case ChangeRequest.EMERGENCY:
			workflow = this.EMERGENCY_WORKFLOW;
			break;
			case ChangeRequest.NORMAL:
			workflow = this.NORMAL_WORKFLOW;
			break;
			case ChangeRequest.STANDARD:
			workflow = this.STANDARD_WORKFLOW;
			break;
			case ChangeRequest.EXPEDITE://CHANGE TO MATCH YOUR TYPE
			workflow = this.NORMAL_WORKFLOW;//CHANGE TO MATCH YOUR WORKFLOW DECLARATION
			break;
		}
		return workflow;
	},
	
	
	
	type: "ChangeRequest"
});

ChangeRequest.newNormal = ChangeRequestSNC.newNormal;

ChangeRequest.newStandard = ChangeRequestSNC.newStandard;

ChangeRequest.newEmergency = ChangeRequestSNC.newEmergency;

ChangeRequest.newExpedite = ChangeRequestSNC.newExpedite;//Update this to match what you called the function above

ChangeRequest.newChange = ChangeRequestSNC.newChange;

 

so you created a new change type but using the same existing normal workflow? did you also add it to the interceptor page? 

I also had to update script include "change request state handler" to call out my new change type.

 

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.prototype = Object.extendsObject(ChangeRequestStateHandlerSNC, {
EXPEDITED:"expedited",
initialize: function(changeRequestGr) {
ChangeRequestStateHandlerSNC.prototype.initialize.call(this, changeRequestGr);
},
_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.EXPEDITED)
this._model = new ChangeRequestStateModel_expedited(this._gr);
},
type: "ChangeRequestStateHandler"
});

State handler is working if I click create new change and choose the type of expedite.  I just can't create it from a UI Action.