java, condition script error : com.ibm.team.rtc.common.scriptengine.UnknownTypeException: SCRIPT_NAME is not a constructor
We have java script ( Conditions type of customization that is used to dynamically determine required attributes),
based on this link, https://jazz.net/wiki/bin/view/Main/AttributeCustomization under title "Conditions".
Our script is simple as below and working fine except for error messages in jazz.log
===========================================
// This script is used in operation behavior condition for attribute Fix Impacts Description.
// When the state is Resolved and Resolution is Fixed and
// Fix Impact check box has any value selected other than Unassigned.
// When the above are matched, if Fix Impact Description is empty user will get an error when saving the work item.
//
dojo.provide("sdi.script.CondFixImpact");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("sdi.script.CondFixImpact", null, {
matches: function(workItem, configuration) {
var state= workItem.getValue(WorkItemAttributes.STATE);
var resol= workItem.getValue(WorkItemAttributes.RESOLUTION)
var FixIMP= workItem.getLabel("sdi.workitem.attribute.FixImpacts");
// console.log(typeof(state))
return (state === "3" && resol === "1" && FixIMP && FixIMP !== "Unassigned");
}
});
})();
===========================================
But in the jazz(ccm) log we see this annoying error messages as pasted below several times.
Is there any thing wrong with the script ? and Why this error is coming ?
Error message in jazz.log
===========================================
2014-05-08 08:27:08,910 [http-bio-9445-exec-51 @@ 08:27 <unauthenticated> /ccm/oslc/context/_DH2-gIwXEeK5gYKZW5OusA/shapes/workitems/rfe] ERROR com.ibm.team.workitem.common - Error invoking work item filter 'com.ibm.team.workitem.valueproviders.CONDITION._EY17sIwLEeKAz9ftjA2pgg'
com.ibm.team.rtc.common.scriptengine.UnknownTypeException: 'sdi.script.CondFixImpact' is not a constructor
at com.ibm.team.rtc.common.scriptengine.environment.ScriptingHelperImplementation.getConstructor(ScriptingHelperImplementation.java:162)
at com.ibm.team.rtc.common.scriptengine.ScriptUtilities$1.run(ScriptUtilities.java:30)
at com.ibm.team.rtc.common.scriptengine.environment.AbstractScriptEnvironment.execute(AbstractScriptEnvironment.java:74)
at com.ibm.team.rtc.common.scriptengine.ScriptUtilities.newInstance(ScriptUtilities.java:27)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider$ProviderCall.getProvider(ScriptAttributeValueProvider.java:203)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider$ProviderCall.<init>(ScriptAttributeValueProvider.java:188)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.matches(ScriptAttributeValueProvider.java:156)
based on this link, https://jazz.net/wiki/bin/view/Main/AttributeCustomization under title "Conditions".
Our script is simple as below and working fine except for error messages in jazz.log
===========================================
// This script is used in operation behavior condition for attribute Fix Impacts Description.
// When the state is Resolved and Resolution is Fixed and
// Fix Impact check box has any value selected other than Unassigned.
// When the above are matched, if Fix Impact Description is empty user will get an error when saving the work item.
//
dojo.provide("sdi.script.CondFixImpact");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("sdi.script.CondFixImpact", null, {
matches: function(workItem, configuration) {
var state= workItem.getValue(WorkItemAttributes.STATE);
var resol= workItem.getValue(WorkItemAttributes.RESOLUTION)
var FixIMP= workItem.getLabel("sdi.workitem.attribute.FixImpacts");
// console.log(typeof(state))
return (state === "3" && resol === "1" && FixIMP && FixIMP !== "Unassigned");
}
});
})();
===========================================
But in the jazz(ccm) log we see this annoying error messages as pasted below several times.
Is there any thing wrong with the script ? and Why this error is coming ?
Error message in jazz.log
===========================================
2014-05-08 08:27:08,910 [http-bio-9445-exec-51 @@ 08:27 <unauthenticated> /ccm/oslc/context/_DH2-gIwXEeK5gYKZW5OusA/shapes/workitems/rfe] ERROR com.ibm.team.workitem.common - Error invoking work item filter 'com.ibm.team.workitem.valueproviders.CONDITION._EY17sIwLEeKAz9ftjA2pgg'
com.ibm.team.rtc.common.scriptengine.UnknownTypeException: 'sdi.script.CondFixImpact' is not a constructor
at com.ibm.team.rtc.common.scriptengine.environment.ScriptingHelperImplementation.getConstructor(ScriptingHelperImplementation.java:162)
at com.ibm.team.rtc.common.scriptengine.ScriptUtilities$1.run(ScriptUtilities.java:30)
at com.ibm.team.rtc.common.scriptengine.environment.AbstractScriptEnvironment.execute(AbstractScriptEnvironment.java:74)
at com.ibm.team.rtc.common.scriptengine.ScriptUtilities.newInstance(ScriptUtilities.java:27)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider$ProviderCall.getProvider(ScriptAttributeValueProvider.java:203)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider$ProviderCall.<init>(ScriptAttributeValueProvider.java:188)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.matches(ScriptAttributeValueProvider.java:156)
Accepted answer
I'm not sure if it would cause that exception in your log, but you're missing a semi-colon at the end of
var resol= workItem.getValue(WorkItemAttributes.RESOLUTION)
I also assume the starting and ending lines with "============" are not actually part of your script.
var resol= workItem.getValue(WorkItemAttributes.RESOLUTION)
I also assume the starting and ending lines with "============" are not actually part of your script.
Comments
Thanks. I will correct the missing semi-colon and see whether error goes away.
Correct. "============" are not actually part of the script.
Looks like missing semi-colon is not the reason for that error. Error is still seen in the log and it is all over the jazz.log.
After investigation and watching the logs over a period of time, Seems the syntax error(missing ';' ) was the cause in the case of this particular script, producing that error in the log, even though it was working fine functionally. Thanks Brian for pointing that out.