"getValue: function(attribute, workItem, configuration) { " Function is not getting called - What could be the possible reasons? I'm using 4.0.6 RTC version
/*******************************************************************************
* Licensed Materials - Property of IBM * (c) Copyright IBM Corporation 2011. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp. *******************************************************************************/ dojo.provide("com.example.ValueProvider"); console.log("dojo.provide"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); console.log("dojo.require"); (function() { //console.log("function call"); var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("com.example.ValueProvider", null, { getValue: function(attribute, workItem, configuration) { console.log("inside getvalue"); var component = workItem.getvalue(WorkItemAttributes.rfeComponent); console.log("component"); var state = workItem.getValue(WorkItemAttributes.STATE); console.log("state"); var type = workItem.getValue(WorkItemAttributes.TYPE); console.log("type"); var override = workItem.getValue("ownerOverride"); if (override == false) { //If RFE is placed in Submitted State and component is "Analytical Functions" or "Data Types" assign ownership to the XXXXXX if ((type === "rfe") && (component === "rfeComponent.literal.l9" || component === "rfeComponent.literal.l13") && (state === "rfeWorkflow.state.s1")){ return configuration.getChild("parameters").getStringDefault("XXXXXX", ""); } // If RFE is placed in Submitted State and for component "Application Development (eg. UDF, Procedures, etc)" or "High Availability and/or Disaster Recovery" assign ownership to the YYYYYY else if ((type === "rfe") && (component === "rfeComponent.literal.l10" || component === "rfeComponent.literal.l15") && (state === "rfeWorkflow.state.s1")){ console.log("output = rfe"); return configuration.getChild("parameters").getStringDefault("YYYYY", ""); } // If RFE is placed in Submitted State and for component "Compression" or "Configuration Parameters" assign ownership to the ZZZZZZZZ. else if ((type === "rfe") && (component === "rfeComponent.literal.l11" || component === "rfeComponent.literal.l12") && (state === "rfeWorkflow.state.s1")){ console.log("output = rfe"); return configuration.getChild("parameters").getStringDefault("ZZZZZZZ", "");} // If RFE is placed in Submitted State and for component "Federation" assign ownership to the AAAAAAAA. else if ((type === "rfe") && (component === "rfeComponent.literal.l14") && (state === "rfeWorkflow.state.s1")){ console.log("output = rfe"); return configuration.getChild("parameters").getStringDefault("AAAAAAAA", "");} else { return workItem.getValue(WorkItemAttributes.OWNER); } } else { return Status.OK_STATUS; } } }); })(); This similar code worked fine in previous versions of CLM, Is there any change in this version? Thanks! |
5 answers
Ralph Schoon (63.7k●3●36●48)
| answered Oct 08 '14, 3:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Some thoughts on this.
First of all, is this a new server? Is return Status.OK_STATUS; which is probably code for a validation script. I would suggest to carefully read: https://jazz.net/library/article/1093 Lab 5, https://jazz.net/wiki/bin/view/Main/AttributeCustomization , https://jazz.net/library/article/1360 and http://www.ibm.com/developerworks/rational/library/rational-team-concert-calculated-fields-work-item/ |
NO this is not a new server. Yes Enable Process attachment Scripts is set to True.
Yes Id's are used and the Parameter for XXXX,YYYY,ZZZZ,AAAA are passed in the Valueprovider tag <configuration-data final="false" id="com.ibm.team.workitem.configuration.providers" xmlns="http://com.ibm.team.workitem/providers"> <valueProviders> <valueProvider id="com.ibm.team.workitem.valueproviders.VALUE_PROVIDER._KcmqwE2MEeSGY8p-15-irw" name="RFEassignowner" providerId="com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider"> <script class="com.example.ValueProvider" path="/workitem/scripts/common/rfeassignowner.js"/> <parameters XXXX="_PFukMOEiEd6aEPpyZ1FE5A" YYYY="_yolScUL3EeSWBczyr5sxWA" ZZZZZ="_c-aK4QpZEd-c65dvdRhmzw" AAAAAAA="_ym8Ts0L3EeSWBczyr5sxWA"/> </valueProvider> </valueProviders> </configuration-data> Note - I tried with the Fill in example feature given in Calculated value. Console .log given inside the getValue: function(attribute, workItem, configuration) { did not print the value given. ccm logs Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function getvalue in object [object com.ibm.team.workitem.common.internal.scripting.WorkItemAPIType]. (rfeassignowner.js#17) 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.notFunctionError(ScriptRuntime.java:3646) at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2186) at org.mozilla.javascript.gen.c42._c2(rfeassignowner.js:17) at org.mozilla.javascript.gen.c42.call(rfeassignowner.js) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003) at org.mozilla.javascript.gen.c42.call(rfeassignowner.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 com.sun.proxy.$Proxy2778.getValue(Unknown Source) at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:67) ... 89 more |
Ralph Schoon (63.7k●3●36●48)
| answered Oct 09 '14, 2:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Here the complete log from https://jazz.net/forum/questions/165177/workitem-customization-using-script-getting-uuid-from-value-provider-showing-error-in-jazz-logs
HOw to get over this error- 2014-10-08 23:12:54,335 [http-bio-9445-exec-5248 @@ 23:12 asukuma@us.ibm.com /jazz/service/com.ibm.team.workitem.common.internal.rest.IWorkItemRestService/workItem2] ERROR com.ibm.team.workitem.common - Error invoking value provider 'com.ibm.team.workitem.valueproviders.VALUE_PROVIDER._DJv4sE9vEeSGY8p-15-irw' com.ibm.team.repository.common.TeamRepositoryException: Unexpected exception type at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.handleException(ScriptAttributeValueProvider.java:281) at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:69) at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValueProvider.getValue(AttributeValueProviderRegistry.java:42) at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:899) at com.ibm.team.workitem.service.internal.save.DependentValueUpdater.handleNotifySave(DependentValueUpdater.java:40) at com.ibm.team.workitem.service.internal.save.WorkItemSaveParticipant.handleNotifySave(WorkItemSaveParticipant.java:32) at com.ibm.team.workitem.service.internal.save.WorkItemSavePreparation.notifySave(WorkItemSavePreparation.java:205) at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.notifyPreSave(WorkItemRepositoryService.java:470) at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.access$3(WorkItemRepositoryService.java:464) at com.ibm.team.workitem.service.internal.WorkItemRepositoryService$1.run(WorkItemRepositoryService.java:354) at com.ibm.team.workitem.service.internal.WorkItemRepositoryService$1.run(WorkItemRepositoryService.java:1) at com.ibm.team.repository.service.internal.PrimitiveTransactionService$3.run(PrimitiveTransactionService.java:163) at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:496) at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$1.run(RepositoryDatabase.java:320) at com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withCurrentConnection(ConnectionPoolService.java:448) at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56) at com.sun.proxy.$Proxy87.withCurrentConnection(Unknown Source) at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:316) at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runInTransaction(RepositoryDatabase.java:271) at com.ibm.team.repository.service.internal.PrimitiveTransactionService.runInTransaction(PrimitiveTransactionService.java:96) at com.ibm.team.repository.service.internal.PrimitiveTransactionService.runInTransaction(PrimitiveTransactionService.java:91) at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56) at com.sun.proxy.$Proxy124.runInTransaction(Unknown Source) at com.ibm.team.repository.service.AbstractService.runInTransaction(AbstractService.java:967) at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.saveTransaction(WorkItemRepositoryService.java:341) at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.save(WorkItemRepositoryService.java:296) at sun.reflect.GeneratedMethodAccessor494.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56) at com.sun.proxy.$Proxy613.save(Unknown Source) at com.ibm.team.workitem.service.internal.WorkItemServer.save(WorkItemServer.java:302) at com.ibm.team.workitem.service.internal.WorkItemServer.saveWorkItems(WorkItemServer.java:151) at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.postWorkItem2(WorkItemRestService.java:482) at sun.reflect.GeneratedMethodAccessor660.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347) at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56) at com.sun.proxy.$Proxy630.postWorkItem2(Unknown Source) at sun.reflect.GeneratedMethodAccessor659.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at com.ibm.team.repository.servlet.AbstractTeamServerServlet.doModelledRestService(AbstractTeamServerServlet.java:530) at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest2(AbstractTeamServerServlet.java:2359) at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest(AbstractTeamServerServlet.java:2153) at com.ibm.team.repository.servlet.AbstractTeamServerServlet.service(AbstractTeamServerServlet.java:1963) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180) at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:76) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:120) at com.ibm.team.repository.server.servletbridge.JazzServlet.service(JazzServlet.java:74) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.ibm.team.repository.server.servletbridge.BridgeFilter.processDelegate(BridgeFilter.java:165) at com.ibm.team.repository.server.servletbridge.BridgeFilter.doFilter(BridgeFilter.java:198) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:336) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:761) Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function getvalue in object [object com.ibm.team.workitem.common.internal.scripting.WorkItemAPIType]. (rfeassignowner.js#18) 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.notFunctionError(ScriptRuntime.java:3646) at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2186) at org.mozilla.javascript.gen.c53._c2(rfeassignowner.js:18) at org.mozilla.javascript.gen.c53.call(rfeassignowner.js) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003) at org.mozilla.javascript.gen.c53.call(rfeassignowner.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 com.sun.proxy.$Proxy1136.getValue(Unknown Source) at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:67) ... 88 more |
Ralph Schoon (63.7k●3●36●48)
| answered Oct 09 '14, 3:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Oct 09 '14, 3:39 a.m.
I took the time to look into this. The script is syntactical incorrect for various reasons. I am unsure why this should have ever run.
I reconstructed the script from a valid example provided by RTC. First observation: the line var component = workItem.getvalue(WorkItemAttributes.rfeComponent);is and has never been a valid statement. There is no WorkItemAttributes.rfeComponent defined in RTc and there probably never was. This should be the string representation of the attribute to be read. E.g. "my.attrib.rfecomponent". This line causes the error above. Second observation: the line below, as already mentioned but ignored, is bogus. This line should not be there. The script has to return a contributor or maybe null, but not a status. Status is returned in validations. else { return Status.OK_STATUS; }My suggestion:
Seed: /******************************************************************************* * Licensed Materials - Property of IBM * (c) Copyright IBM Corporation 2011. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp. *******************************************************************************/ dojo.provide("com.example.ValueProvider"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("com.example.ValueProvider", null, { getValue: function(attribute, workItem, configuration) { return workItem.getValue(WorkItemAttributes.OWNER); } }); })();
Comments After the script finally runs, remove the log outputs to avoid the performance penalty of a chatty script.
|
I tried with the suggestions provided,
When I use Component a Custom enumeration field, it breaks. Is there a way to compare Custom enumeration field with other RTC provided value ? Can we hard code that in this feature. In Chrome - Development Tool I see the below error Problems executing value provider for {0}: undefined is not a function. TypeError: undefined is not a function at dojo.declare.getValue (rfeassignowner.js:23:36) JS- dojo.provide("com.example.setownerbycomponent"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("com.example.setownerbycomponent", null, { getValue: function(attributeId, workItem, configuration) { var type = workItem.getValue(WorkItemAttributes.TYPE); var state = workItem.getValue(WorkItemAttributes.STATE); var component = workItem.getvalue(WorkItemAttributes.rfeComponent); if (workItem.getValue(WorkItemAttributes.TYPE) === "rfe" && workItem.getValue(WorkItemAttributes.STATE) === "rfeWorkflow.state.s1" && workItem.getvalue(WorkItemAttributes.rfeComponent) === "rfeComponent.literal.l9"){ return configuration.getChild("parameters").getStringDefault("XXXXXX", ""); } else { console.log("output test"); return workItem.getValue(WorkItemAttributes.OWNER); } } }); })(); |
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.