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? |
19 answers
Hi Russel, 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 |
Ralph Schoon (63.5k●3●36●46)
| answered Nov 07 '11, 7:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,
this works the following way:
|
Hi, 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? |
Ralph Schoon (63.5k●3●36●46)
| 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. |
Hi Russel, 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); |
Ralph Schoon (63.5k●3●36●46)
| 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-) |
Hi, will do |
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 |
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' |
Ralph Schoon (63.5k●3●36●46)
| 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
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.