It's all about the answers!

Ask a question

Attribute Customization Scripted Based Default Values


derry davis (23221916) | asked Oct 26 '11, 4:46 p.m.
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");

}
});
})();

8 answers



permanent link
Christophe Elek (2.9k13021) | answered Oct 27 '11, 6:54 p.m.
JAZZ DEVELOPER
Use Firebug, put a breakpoint in the javascript, does it reach it ?
I will try it on my side

permanent link
Christophe Elek (2.9k13021) | answered Oct 27 '11, 7:31 p.m.
JAZZ DEVELOPER
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 ?

permanent link
Ralph Schoon (63.2k33646) | answered Oct 28 '11, 4:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

permanent link
derry davis (23221916) | answered Oct 28 '11, 4:14 p.m.
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.

permanent link
derry davis (23221916) | answered Oct 28 '11, 4:33 p.m.
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

permanent link
Christophe Elek (2.9k13021) | answered Nov 01 '11, 6:19 p.m.
JAZZ DEVELOPER
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;

}
});
})();

permanent link
Steven Jin (10697) | answered Nov 03 '11, 7:58 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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;
}
});
})();

permanent link
Steven Jin (10697) | answered Nov 04 '11, 10:09 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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;
}
});
})();

Your answer


Register or to post 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.