It's all about the answers!

Ask a question

Attribute Customization:CalculatedValue of custom attribute


Vinay Kumar AV (17923337) | asked Sep 06 '11, 10:48 a.m.
Hi all,

I am trying to create an Attribute Customization for Calculated Value of a custom variable.

The scenario for the attribute customization is as follows: I want to read the string form a custom attribute 'A' of a text box and update another custom attribute 'B' (a multi line text box) with the text taken from attribute 'A'.

Please advise how is this possible? I am stuck at this point. Thanks in advance!!

The script I wrote is as follows:

I added two custom attributes 'test_string' and 'test _string01' to the Task WI. I basically want to read the contents of 'test_string' and apply the same as appended value to 'test string 01'. I created a script as below:

dojo.provide("org.example.workitems.providers.CalculatedValueString");


(function() {
dojo.declare("org.example.workitems.providers.CalculatedValueString", null, {

getValue: function(attributeId, workItem, configuration) {
var test_stringAttribute= configuration.getChild("test_string").getIdentifier();
var test_string=workItem.getValue(test_stringAttribute);
return test_string;
}
});
})();



Regards
Vinay

4 answers



permanent link
Indradri Basu (1.8k1514) | answered Sep 12 '11, 9:03 p.m.
Can someone please help me here? Thanks in advance!!


Hi Vinay,

This should work for you.

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("net.example.calculatedValueString", null, {

getValue: function(attribute, workItem, configuration) {

var test_stringAttribute = workItem.getValue("com.ibm.team.workitem.attribute.test_string"); // Note: This is the attribute ID and not the name
var test_string = test_stringAttribute;

return test_string;

}
});
})();

Also make sure you have added test_string in the dependencies list of attribute test_string01

-- Indradri

Comments
Morten Madsen commented Nov 23 '12, 5:29 a.m.

heh, that last sentence "Also make sure...." just saved my day :-D


permanent link
Vinay Kumar AV (17923337) | answered Sep 12 '11, 9:16 a.m.
Can someone please help me here? Thanks in advance!!

permanent link
Alan Kan (6111310) | answered Sep 14 '11, 1:38 a.m.
I have a similar problem. I would like to assign the value of a custom "contributor" attribute to the "Owner". I tried using workItem.getValue("com.ibm.team.workitem.attribute.test_string") to get the value of the custom attribute. But it always returns null. Any ideas?

Cheers,
Alan


Hi Vinay,

This should work for you.

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("net.example.calculatedValueString", null, {

getValue: function(attribute, workItem, configuration) {

var test_stringAttribute = workItem.getValue("com.ibm.team.workitem.attribute.test_string"); // Note: This is the attribute ID and not the name
var test_string = test_stringAttribute;

return test_string;

}
});
})();

Also make sure you have added test_string in the dependencies list of attribute test_string01

-- Indradri

Comments
Morten Madsen commented Nov 23 '12, 5:28 a.m. | edited Nov 23 '12, 5:29 a.m.

moved this comment


permanent link
Indradri Basu (1.8k1514) | answered Sep 15 '11, 5:23 a.m.
I have a similar problem. I would like to assign the value of a custom "contributor" attribute to the "Owner". I tried using workItem.getValue("com.ibm.team.workitem.attribute.test_string") to get the value of the custom attribute. But it always returns null. Any ideas?

Cheers,
Alan


Hi Vinay,

This should work for you.

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("net.example.calculatedValueString", null, {

getValue: function(attribute, workItem, configuration) {

var test_stringAttribute = workItem.getValue("com.ibm.team.workitem.attribute.test_string"); // Note: This is the attribute ID and not the name
var test_string = test_stringAttribute;

return test_string;

}
});
})();

Also make sure you have added test_string in the dependencies list of attribute test_string01

-- Indradri


I would probably suspect if you have passed the correct id of your custom attribute in the getValue() and also if you have listed the owner attribute in the dependencies list of the custom attribute.

-- Indradri

Your answer


Register or to post your answer.