Script based Default Value
Hi
I'm trying to create a new "Script Based Default Value" customization. It is simple just to hard code the owner of a certain type of workitem. I have created calculated value scripts before and they run ok.
But I'm having trouble with the default value, is the structure the same?
This is my code :
Thanks
|
Accepted answer
The function should be getDefaultValue, not getValue. You can use the "Fill in example" link to get the skeleton of the script to avoid such simple mistake.
Cesar Sasaki selected this answer as the correct answer
Comments
Cesar Sasaki
commented Jul 04 '17, 2:05 a.m.
Hi Donald
I'm still having trouble using this code :
getDefaultValue: function(attribute, workItem, configuration) {
var wi_type = workItem.getDefaultValue(WorkItemAttributes.TYPE);
var wi_owner = workItem.getDefaultValue(WorkItemAttributes.OWNER);
if (wi_type == "task"){
wi_owner = "_p_g14CR6EeWmoeAO1lg85w";
}
return wi_owner;
Donald Nong
commented Jul 04 '17, 3:08 a.m.
More details please?
Ralph Schoon
commented Jul 04 '17, 4:26 a.m.
| edited Jul 04 '17, 4:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The code above is bogus I suggest to read the instructions again https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_default_values
workItem.getDefaultValue(WorkItemAttributes.TYPE);
must be workItem.getValue(WorkItemAttributes.TYPE);
the function was wrong as Donald correctly stated. Also Default values have very limited value since there is almost no data available on creation of the work item as Don also stated.
Cesar Sasaki
commented Jul 04 '17, 11:30 a.m.
I changed my script and worked I needed to add this :
(function() {
dojo.declare("default_value.owner", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var wi_type = workItem.getValue(WorkItemAttributes.TYPE);
|
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.