Attribute Customization Scripted Based Default Values
I'm receiving an error when I use the sample code provided with the Script Based Values option under the Default Values section of attribute customization. The sample code below throws "Error invoking default value provider 'com.ibm.team.workitem.valueproviders.DEFAULT_VALUE_PROVIDER._8IEaEPwvEeCQiOpI0UXknQ'"
It will return text fine however (shown remarked out below). Advice?
/*******************************************************************************
* 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.DefaultValueProvider");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
return workItem.getValue(attribute);
//return("test");
}
});
})();
It will return text fine however (shown remarked out below). Advice?
/*******************************************************************************
* 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.DefaultValueProvider");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
return workItem.getValue(attribute);
//return("test");
}
});
})();
8 answers
Hi,
this is still experimental and needs to be switched on in the CCM server administration or in the teamserver.properties using
com.ibm.team.workitem.process.scripts.enabled=true
I forgot and the logs show issues loading the script and a similar error after that.
Hi Ralph,
It is enabled, I just checked the teamserver.properties file.
Thanks.
Derry.
RTC 3.0.1
Created new Project Area
Created new Default Value - Script
Added return('test'); ,<-- notice ' not "
creates a SmallString attribute
Added default value to it
Works for me in Eclipse and Web clients
Can you confirm ?
Yes that works.
This does not work --> return workItem.getValue(attribute);
-Derry
try this...
the state may not exactly be what you need, but that should get you started
******
dojo.provide("com.example.DefaultValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var status = workItem.getValue(WorkItemAttributes.STATE);
var TestString = "";
if ((status === "s1")) { // Initialize
TestString = 'Active';
} else {
TestString = 'Done';
}
return TestString;
}
});
})();
the state may not exactly be what you need, but that should get you started
******
dojo.provide("com.example.DefaultValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var status = workItem.getValue(WorkItemAttributes.STATE);
var TestString = "";
if ((status === "s1")) { // Initialize
TestString = 'Active';
} else {
TestString = 'Done';
}
return TestString;
}
});
})();
Christophe,
I tested the new script, the following line
var status = workItem.getValue(WorkItemAttributes.STATE);
, does not seem to do anything. status is always NULL. Therefore, the code will always return "Active_Iteration".
Here is my modified test code, which will give me "NULL" all the time:
dojo.provide("com.example.DefaultValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var status = workItem.getValue(WorkItemAttributes.STATE);
var TestString = "";
if (status) {
if ((status === "s1")) { // Initialize
TestString = 'Done_Iteration';
} else {
TestString = 'Active_Iteration';
}} else {TestString = 'NULL';}
return TestString;
//return status;
}
});
})();
I tested the new script, the following line
var status = workItem.getValue(WorkItemAttributes.STATE);
, does not seem to do anything. status is always NULL. Therefore, the code will always return "Active_Iteration".
Here is my modified test code, which will give me "NULL" all the time:
dojo.provide("com.example.DefaultValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var status = workItem.getValue(WorkItemAttributes.STATE);
var TestString = "";
if (status) {
if ((status === "s1")) { // Initialize
TestString = 'Done_Iteration';
} else {
TestString = 'Active_Iteration';
}} else {TestString = 'NULL';}
return TestString;
//return status;
}
});
})();
Derry,
The following code should work, and will return something meaningful:
dojo.provide("com.example.DefaultValueProvider");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var TestString = "";
TestString = dojo.toJson(attribute);
return TestString;
}
});
})();
The following code should work, and will return something meaningful:
dojo.provide("com.example.DefaultValueProvider");
(function() {
dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var TestString = "";
TestString = dojo.toJson(attribute);
return TestString;
}
});
})();