Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

WI attribute customization: get custom attribute value

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?

0 votes



19 answers

Permanent link
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

1 vote


Permanent link
Hi,

this works the following way:


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

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

workItem.getValue(custom);

0 votes


Permanent link
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?

0 votes


Permanent link
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.

0 votes


Permanent link
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);

0 votes


Permanent link
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-)

0 votes


Permanent link
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

0 votes


Permanent link

"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

0 votes


Permanent link

"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'

0 votes


Permanent link
Thanks for posting. I had no time to try....

0 votes

1–15 items
page 1of 1 pagesof 2 pages

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,950

Question asked: Nov 07 '11, 7:04 a.m.

Question was seen: 17,170 times

Last updated: Jun 28 '12, 4:29 p.m.

Confirmation Cancel Confirm