Has anyone else run into problems with Script based attribute calculated values in RTC 5.0 web?
Error: com.ibm.team.repository.web.transport.ServiceRequest(): invalid requestParameters parameter: [object Object]
The error from IE is basically the same:
Message: com.ibm.team.repository.web.transport.ServiceRequest(): invalid requestParameters parameter: [object Object]
Line: 21518
Char: 1
Code: 0
URI: https://gdccm01.gddsi.com:9443/ccm/web/_js/?include=F~&etag=JYhtNwwjKTa_en_US&_proxyURL=%2Fccm&ss=FjqrT&locale=en-us
--- The code in my script is included below:
dojo.provide("com.gdc4s.rtc.ValueProvider.TimeSpentStatusUpdate"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.gdc4s.rtc.ValueProvider.TimeSpentStatusUpdate", null, {
getValue: function(attribute, workItem, configuration) {
var state = workItem.getValue(attribute);
var tspent = workItem.getValue(WorkItemAttributes.TIME_SPENT);
var rtype = workItem.getValue(WorkItemAttributes.TYPE);
var newState = state;
/* For 'task' State of '1' is New, '2' is In Progress -- the "S" is stripped off for these states */
/* For 'defect' or 'enhancement', State of '1' is Triage, 'com.ibm.team.workitem.defectWorkflow.state.s9' is Assessing */
if (tspent > 0)
{
if ((rtype == "task") && (state == "1"))
{
newState = "2";
}
else if (((rtype == "defect") || (rtype == "enhancement")) && (state == "1"))
{
newState = "com.ibm.team.workitem.defectWorkflow.state.s9";
}
}
return newState;
}
});
})();
One answer
Another thought is: why do the state ID's look so different?
If a work item is in the new state, the state is null (at least in Java). After the save it is "New". You might want to test for this and take it into consideration.
Comments
I tried adding try/catch blocks and it actually doesn't catch any error... I also stripped my script down to just 2 statements - get the current state and return that as the value. This resulted in an error still being thrown. Actually, the error is thrown multiple times (2+ -- seems to vary). It seems the script is invoked multiple times, the first time goes through with no error but somehow causes a chain reaction of follow on errors. This worked fine in 4.0.2...
The error I am getting is:
"Problems executing value provider for {0}: state is null. .getValue@https://gdccm01.gddsi.com:9443/ccm/web/_js/?exclude=F&include=com.ibm.team.workitem.web.ui.internal.page.WorkItemPageView&ss=FjqrT&_proxyURL=%2Fccm&locale=en-us line 27449 > eval:30:1
.getValue@https://gdccm01.gddsi.com:9443/ccm/web/_js/?exclude=F&include=com.ibm.team.workitem.web.ui.internal.page.WorkItemPageView&ss=FjqrT&_proxyURL=%2Fccm&locale=en-us:29775:1 ..... (more deleted for space)
Calculated value provider are called multiple times, based on changes in attributes they depend on. This is quite normal.
I can only suggest again, to either put more output in the scripts (like in https://jazz.net/library/article/1093 Lab 5) so that the log contains data that helps, or to debug the scripts e.g. as described here: https://jazz.net/library/article/1360 . Somehow you get a null value or something. The error provided does not help and the error is not going away on its own.
Comments
Jamie Berry
Jan 21 '15, 2:09 p.m.Additional information. I have 2 other calculated value scripts that work okay. The other two apply to a Date field and the corrected estimate field. It might be possible that the issue is with the attempt to set the state of the work item...
Jamie Berry
Jan 21 '15, 4:00 p.m.Okay, I put some console.log statements in and ran again in Firefox with the console showing. Here is what I received (truncated ... to fit)
"In TimeSpentStatusUpdate" _js:26
"internalState = 2, tspent = 1800000" _js:33
"newState = 2" _js:48
"Problems executing value provider for {0}: state is null. .getValue@https://gdccm01.gddsi.com:9443/ccm/web/_js/?exclude=F&include=com.ibm.team.workitem.web.ui.internal.page.WorkItemPageView&ss=FjqrT&_proxyURL=%2Fccm&locale=en-us line 27449 > eval:28:1
.getValue...
"Problems executing value provider for {0}: state is null...
"In TimeSpentStatusUpdate" _js:26
"internalState = null, tspent = 1800000" _js:33
"newState = null" _js:48
"Problems executing value provider for {0}: state is null...
"In TimeSpentStatusUpdate" _js:26
"internalState = null, tspent = 900000" _js:33
"newState = null" _js:48
...
Donald Nong
Jan 23 '15, 12:39 a.m.It appears that somewhere in the middle a variable gets a null value. I have found that JavaScript can get different results when running on client side comparing to running on server side, probably due to the different JavaScript engine.