Change Request Client Script 'Show valid states values' not running on new change type

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
  2. Test in UAT

What I have found is that when clicking State, the Option is there to choose all available states, instead of seeing just the next state available.

find_real_file.png

New should show Develop and Implement in UAT only.

I debugged with field watcher, and have found that the client script 'Show valid states values' is not running

find_real_file.png

In my personal development instance, the client script shows as running when using the field watcher.  It is probably worth noting that the change request here was heavily modified by the implementer, however, I cannot see any of their scripts running on the state field with the field watcher so not sure something is cancelling it out, but rather something is wrong with the script includes that I have created for the new change type.

Below are the script inlcudes that  I have created for the new change type.  Can anyone see why the client script is not running?

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:Minor,
	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_im_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

Jack
Tera Guru

Hi Brendan,

I thinks you should be check:

1) The value of new type: "Minor" or "minor"

2) Update "ChangeRequestStateHandler" for new type:

MINOR: "<value of new type>",

=> I thinks you have a typo mistake when updating "ChangeRequestStateHandler"

 

Hope this help!

View solution in original post

13 REPLIES 13

Yes. The client script is running. You should get 3 pop ups, one by one. Did you get the rest of the 2 pop-ups as well?


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

hey,

 

I got 2 popups, the other on:

find_real_file.png

Good. So you are not getting the valid states from below business rule.

 

find_real_file.png

 

Can you check your system log, if you get any message State is not valid or no more future state?

 

find_real_file.png


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

Hey,

Yep, 3 warning logs were logged.  They are below.

the value of the change type is actually minorv2, and I have rectified this in the ChangeRequestStateHandler script after Jack pointed out there could be a typo.  still not working but at least we are getting debugs.

 

org.mozilla.javascript.EcmaError: "minorv2" is not defined.
Caused by error in sys_script_include.7d127e37cb100200d71cb9c0c24c9cff.script at line 15

12: ChangeRequestStateHandler.DEVELOP_AND_IMPLEMENT_IN_UAT = "develop_and_implement_in_uat";
13: ChangeRequestStateHandler.TEST_IN_UAT = "test_in_uat";
14:
==> 15: ChangeRequestStateHandler.prototype = Object.extendsObject(ChangeRequestStateHandlerSNC, {
16: MINOR:minorv2,
17: initialize: function(changeRequestGr) {
18: ChangeRequestStateHandlerSNC.prototype.initialize.call(this, changeRequestGr);

===================================================================

org.mozilla.javascript.EcmaError: "minorv2" is not defined.
Caused by error in sys_script.0aa20f7ec39132001488b731c1d3ae9e.script at line 4

1: var ChangeRequestStateHandler = Class.create();
2:
3: // All references to statehandler constants should be through this class ChangeRequestStateHandler
==> 4: ChangeRequestStateHandler.DRAFT = ChangeRequestStateHandlerSNC.DRAFT;
5: ChangeRequestStateHandler.ASSESS = ChangeRequestStateHandlerSNC.ASSESS;
6: ChangeRequestStateHandler.AUTHORIZE = ChangeRequestStateHandlerSNC.AUTHORIZE;
7: ChangeRequestStateHandler.SCHEDULED = ChangeRequestStateHandlerSNC.SCHEDULED;

===================================================================

org.mozilla.javascript.EcmaError: "minorv2" is not defined.
Caused by error in sys_script.0aa20f7ec39132001488b731c1d3ae9e.script at line 1

==> 1: var ChangeRequestStateHandler = Class.create();
2:
3: // All references to statehandler constants should be through this class ChangeRequestStateHandler
4: ChangeRequestStateHandler.DRAFT = ChangeRequestStateHandlerSNC.DRAFT;

 

I think you need to modify ChangeRequestStateHandlerSNC or create a copy of ChangeRequestStateHandlerSNC and modify it.

 

And then update ChangeRequestStateHandler to use the new ChangeRequestStateHandlerSNC


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