It's all about the answers!

Ask a question

WI attribute customization: get custom attribute value


Russell Norlund (17211724) | asked Nov 07 '11, 7:04 a.m.
In work item customization getting the value of a built in attribute is straight forward i.e. com.ibm.team.workitem.api.common.WorkItemAttributes class which contains the the string constants that are used to access built-in attributes of work items such as SEVERITY, PRIORITY etc.

Is there any other class which you can use to get the values of custom attributes?

19 answers



permanent link
Russell Norlund (17211724) | answered Nov 07 '11, 10:44 a.m.
Hi Russel,

I missed that you were working in the JavaScript area. The code below would be for the plain Java API. I have not tried to set the category in Java script. I would assume it would only work with strings, if at all.

From the documentation in the WiKi it looks like we don't have a good API to access Item data.


Hi Ralph, After some experimentation I got it to work by passing the custom attribute as a parameter in the process configuration source (xml) e.g.:

<valueProvider>
<script>
<parameters>

You can accesss this in the javascript e.g.:

getValue: function(attributeId, workItem, configuration) {
var type_id = configuration.getChild("parameters").getStringDefault("typeAttribute", "");
return workItem.getValue(type_id);

XML parameter should be:

<parameters>

were typeid is the id of a custom attribute

permanent link
Ralph Schoon (63.1k33646) | answered Nov 07 '11, 7:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

this works the following way:


IWorkItemClient workItemClient= (IWorkItemClient) fTeamRepository.getClientLibrary(IWorkItemClient.class);

IAttribute custom = workItemClient.findAttribute(fProjectArea,
fCustomStringAttributeID, null);

workItem.getValue(custom);


permanent link
Russell Norlund (17211724) | answered Nov 07 '11, 9:24 a.m.
Hi,

this works the following way:


IWorkItemClient workItemClient= (IWorkItemClient) fTeamRepository.getClientLibrary(IWorkItemClient.class);

IAttribute custom = workItemClient.findAttribute(fProjectArea,
fCustomStringAttributeID, null);

workItem.getValue(custom);



Hi Ralph, thanks for the reply. Is the code shown java? If so can this work with the Work Item Attribute Customization? I thought it could only use javaScript?

permanent link
Ralph Schoon (63.1k33646) | answered Nov 07 '11, 9:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Russel,

I missed that you were working in the JavaScript area. The code below would be for the plain Java API. I have not tried to set the category in Java script. I would assume it would only work with strings, if at all.

From the documentation in the WiKi it looks like we don't have a good API to access Item data.

permanent link
Russell Norlund (17211724) | answered Nov 07 '11, 10:38 a.m.
Hi Russel,

I missed that you were working in the JavaScript area. The code below would be for the plain Java API. I have not tried to set the category in Java script. I would assume it would only work with strings, if at all.

From the documentation in the WiKi it looks like we don't have a good API to access Item data.


Hi Ralph, After some experimentation I got it to work by passing the custom attribute as a parameter in the process configuration source (xml) e.g.:

<valueProvider>
<script>
<parameters>

You can accesss this in the javascript e.g.:

getValue: function(attributeId, workItem, configuration) {
var type_id = configuration.getChild("parameters").getStringDefault("typeAttribute", "");
return workItem.getValue(type_id);

permanent link
Ralph Schoon (63.1k33646) | answered Nov 07 '11, 11:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

yes, that is documented in the WiKi (see url below).

Please be aware that only a limited number of types are really supported details can be found in https://jazz.net/wiki/bin/view/Main/AttributeCustomization.

You should be able to access the attributes just using the ID as string. What I am not sure of is if you can actually set an attribute like Category/Found in. I have experienced for contributors you just get the ID back and you cant actually use that to set a contributor type attribute. If you can set the category, please post your solution, I am currently collecting samples 8-)

permanent link
Russell Norlund (17211724) | answered Nov 07 '11, 11:42 a.m.
Hi,

yes, that is documented in the WiKi (see url below).

Please be aware that only a limited number of types are really supported details can be found in https://jazz.net/wiki/bin/view/Main/AttributeCustomization.

You should be able to access the attributes just using the ID as string. What I am not sure of is if you can actually set an attribute like Category/Found in. I have experienced for contributors you just get the ID back and you cant actually use that to set a contributor type attribute. If you can set the category, please post your solution, I am currently collecting samples 8-)


will do

permanent link
Henry Armburg Jennings (13076) | answered Nov 18 '11, 11:30 a.m.

"You should be able to access the attributes just using the ID as string. What I am not sure of is if you can actually set an attribute like Category/Found in."


Hi,

I am trying to simply access the attribute 'Category' and have been unable to do so. This code returns null for me:

var teamValue = workItem.getValue("com.ibm.team.workitem.attribute.category");

console.log("teamValue : " + teamValue);

Did you manage to access the category attribute? (I don't need to actually set the attribute but set another attribute dependent upon what the Category attribute is.)

Thanks in advance,

henry

permanent link
Henry Armburg Jennings (13076) | answered Nov 18 '11, 12:26 p.m.

"You should be able to access the attributes just using the ID as string. What I am not sure of is if you can actually set an attribute like Category/Found in."


Hi,

I am trying to simply access the attribute 'Category' and have been unable to do so. This code returns null for me:

var teamValue = workItem.getValue("com.ibm.team.workitem.attribute.category");

console.log("teamValue : " + teamValue);

Did you manage to access the category attribute? (I don't need to actually set the attribute but set another attribute dependent upon what the Category attribute is.)

Thanks in advance,

henry

I have found the answer to this - use 'WorkItemAttributes.FILED_AGAINST'

permanent link
Ralph Schoon (63.1k33646) | answered Nov 18 '11, 12:48 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Thanks for posting. I had no time to try....

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.