It's all about the answers!

Ask a question

Has anyone else run into problems with Script based attribute calculated values in RTC 5.0 web?


Jamie Berry (14014196) | asked Jan 21 '15, 12:22 p.m.
edited Jan 21 '15, 2:12 p.m.
We have a script based Calculated Value attribute customization that will set the state of a work item to In Progress whenever a non-zero time spent value is set while the state is new (basic behavior).  This worked fine in 4.0.2 from the web and works fine in the Eclipse Clients in 5.0.1.  However, when trying to exercise this code from the web for 5.0.1, I am getting errors.  I am using Firefox 31.0 ESR and IE 8.0 as my web browsers.  The error I get in Firefox is:

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;
       }
    });
})();

Comments
Jamie Berry commented 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 commented 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 commented 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.

One answer



permanent link
Ralph Schoon (63.5k33646) | answered Jan 23 '15, 2:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
It might also make sense to wrap your code with a try catch block to see where the error happens exactly.
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
Jamie Berry commented Jan 27 '15, 11:33 a.m.

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)


Ralph Schoon commented Jan 28 '15, 4:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.