Error when trying to implement a Default Value script
Hi
We are using RTC 5.0
I am trying to implement a Default Value into the Estimate Attribute based on a selected value in a Custom Attribute field ,ie,
If the value selected in the custom attribute field = Medium Enhancement, then the Estimate Field should default to a value of 60 Hours.
I used the following script;
dojo.provide("com.example.estimatedTime");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var estimatedTime= dojo.declare("com.example.estimatedTime", null, {
getDefaultValue: function(attribute, workitem, configuration) {
var estimatedTime = parseFloat(workitem.getLabel(String "service_Classification"));
if estimatedTime === "service_Classification.literal.l6"); {
return "30";
}
else if estimatedTime === "service_Classification.literal.l13"); {
return "60";
}
else if estimatedTime === "service_Classification.literal.l8"); {
return "90" ;
}
}
});
})();
I am getting the following error;
2016-04-23 16:11:30,753 [ccm: AsynchronousTaskRunner-2 @@ 16:11] ERROR com.ibm.team.workitem.common - Error invoking value provider 'com.ibm.team.workitem.valueproviders.VALUE_PROVIDER._uLJToAlaEeauvdaUeukNjg'
com.ibm.team.rtc.common.scriptengine.UnknownTypeException: 'com.example.estimatedTime' is not a constructor
Any and all assistance will be greatly appreciated.
Kind Regards
Glenn
|
Accepted answer
Your script is malformed, hence the function is invalid. It looks a bit funny, why do you have the "var estimatedTime= dojo.declare(..." bit? It should've just been "dojo.declare(...". Maybe you just copied something to the wrong place without realizing it?
Glenn Watkins selected this answer as the correct answer
Comments
Glenn Watkins
commented Apr 26 '16, 11:04 a.m.
Hi Donald
Please see below
Kind Regards
Glenn
Hi Donald
Thanks for your reply and advice, I have removed the bit as you mentioned and the script now looks as follows;
dojo.provide("com.example.estimatedTime");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.estimatedTime", null, {
getDefaultValue: function(attribute, workitem, configuration) {
var estimatedTime = parseFloat(workitem.getLabel(String "service_Classification"));
if estimatedTime === "service_Classification.literal.l6"); {
return "30";
}
else if estimatedTime === "service_Classification.literal.l13"); {
return "60";
}
else if estimatedTime === "service_Classification.literal.l8"); {
return "90" ;
}
}
});
})();
I am still not getting the field to populate and the logs are giving the same error message. I would appreciate any help and advice on this.
Kind Regards
Glenn
Donald Nong
commented Apr 26 '16, 9:47 p.m.
Glenn, you really have to work on your coding skills, I'm sorry to say. It takes much more time to figure out what's wrong with your code than write my own version. Here is a list of the errors that I can spot, so far.
|
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.