Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Error Invoking Calculated Value Script

I'm attempting to develop a Calculated-Value Script for RTC 3.0.1.2 that will update an attribute based on a particular state change.

I have already run into the issue where workItem.getValue(WorkItemAttributes.STATE) always seems to return null. However, (for better or worse) I've found a workaround using workItem._proxy.object.attributes.internalState.label.
I've come across a few posts in the forum where people have identified the issue of WorkItemAttributes.STATE being null. However, I didn't see any agreement on what the underlying issue was.

Additionally, the script fails to run at all on save (as well as if I set Status as a dependency for the attribute). After further investigation, I found this error in the ccm log:

2012-05-28 20:54:25,520 ERROR com.ibm.team.workitem.common - Error invoking value provider 'com.ibm.team.workitem.valueproviders.VALUE_PROVIDER._Z1bfoKa6EeGhdfd81nRvQA'
com.ibm.team.repository.common.TeamRepositoryException: Unexpected exception type
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.handleException(ScriptAttributeValueProvider.java:229)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:64)
at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValueProvider.getValue(AttributeValueProviderRegistry.java:43)
at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:898)
at com.ibm.team.workitem.common.internal.WorkItemCommon.createWorkItem(WorkItemCommon.java:221)
at com.ibm.team.workitem.common.internal.WorkItemCommon.createWorkItem2(WorkItemCommon.java:176)
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.createWorkItem(WorkItemRestService.java:2048)
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getWorkItem(WorkItemRestService.java:1748)
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getValues(WorkItemRestService.java:1330)
at sun.reflect.GeneratedMethodAccessor1105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:370)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:356)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at $Proxy776.getValues(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1104.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.doModelledRestService(AbstractTeamServerServlet.java:504)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest2(AbstractTeamServerServlet.java:1869)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest(AbstractTeamServerServlet.java:1725)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.service(AbstractTeamServerServlet.java:1634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:120)
at com.ibm.team.repository.server.servletbridge.JazzServlet.service(JazzServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:420)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:811)
Caused by:
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "object" from undefined (updateDefectTimesReopened.js#14)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3595)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1381)
at org.mozilla.javascript.gen.c1014._c2(updateDefectTimesReopened.js:14)
at org.mozilla.javascript.gen.c1014.call(updateDefectTimesReopened.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
at org.mozilla.javascript.gen.c1014.call(updateDefectTimesReopened.js)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler$1.run(AbstractInvocationHandler.java:160)
at com.ibm.team.rtc.common.scriptengine.environment.AbstractScriptEnvironment.execute(AbstractScriptEnvironment.java:74)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler.invoke(AbstractInvocationHandler.java:156)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invokeGeneric(AbstractInvocationHandler.java:141)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:95)
at $Proxy2383.getValue(Unknown Source)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:62)
... 46 more


I have checked the usual issues (scripts being enabled on the server, WorkItemAttributes being defined as com.ibm.team.workitem.api.common.WorkItemAttributes) and have not been able to resolve the issue. I have even been able to set an arbitrary dependency (ex: the planned for field), made a change to that field, and seen the script execute successfully.

I'm somewhat at a loss as to the issue here. I'm not sure if its a limitation/defect in this version of RTC or if it may be an issue with my code. I can post the script; However, it is fairly simple, and as I stated earlier, it will execute under different circumstances.

Any thoughts?

0 votes



2 answers

Permanent link
Hi,

have you tried to add the state attribute as dependency to the attribute that has the value provider? I got the "null" when I didn't.

I am not aware that there is a way to get the old state value (to determine that there is a state change). You would have to calculate the value every time.

If you happen to run into how the old state can be accessed, please publish it here.

0 votes


Permanent link
Hi,

have you tried to add the state attribute as dependency to the attribute that has the value provider? I got the "null" when I didn't.

I am not aware that there is a way to get the old state value (to determine that there is a state change). You would have to calculate the value every time.

If you happen to run into how the old state can be accessed, please publish it here.


Yes, I've tried adding the 'Status' attribute as a dependency to the value provider and still get the Null value.

In my prodding around behind the scenes a bit, I had noticed that the _proxy.object.attributes.* seemed to represent the current values of attributes, and the _proxy.storedObject.attributes.* seemed to represent the current saved values of the work item attributes. It was there that I was hoping to identify the old state.
This theory does seem to hold true for some/most attributes. However, upon further observation, it does not hold true for the internalState attribute.

The further I dig into this, the more I get the impression that the scripting framework simply isn't well enough developed (as of 3.0.1.2) to get the functionality that I was hoping for...

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: May 28 '12, 9:10 p.m.

Question was seen: 5,125 times

Last updated: May 28 '12, 9:10 p.m.

Confirmation Cancel Confirm