It's all about the answers!

Ask a question

How to get the custom attributes programatically?


0
1
Dnyanesh Markad (291825) | asked Dec 28 '12, 8:25 a.m.
Hi,
I want to check values of custom attributes for certain conditions. How to get the custom attribute values???

Thanks,
Dnyanesh

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered Dec 31 '12, 7:54 a.m.
the problem we have is that you haven't said what kind of program

client
server
java
javascript
OLSC
??

here are links to some code in Java for Client and Server (Advisor or Participant)
that accesses all the attributes..

client - see the 'accepted answer' here https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
server - see the third post here https://jazz.net/forum/questions/76276/how-to-get-the-value-selected-by-user-from-a-drop-down-list
Dnyanesh Markad selected this answer as the correct answer

Comments
Dnyanesh Markad commented Jan 02 '13, 12:56 a.m.

Hi all ,
I am developing server side code for advisor . Now I have defined custom attribute custA which is of type enumeration say Enum1. Now I have added that attribute in workitem. While saving the workitem I have selected multiple number of items say 3 from custom attribute custA. Now I just want the number of selected items from the list means how to get that 3 programatically.? means my code should return 3.

Thanks,
Dnyanesh


Ralph Schoon commented Jan 02 '13, 5:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I haven't really done this, as I see it there are two options using Java in a server extension.

1. If the attribute is of type String, the multi selection is, unfortunately, just done by concatenating the enumeration literals in the string, separated by ; or , or something like that. If you get and print the attribute value, you should be able to understand the format. In this case the number is just either the number of strings you get back with value.split(";"). You can also count the separators.
2. If the attribute is a list type, you should get it back as some list and be able to use the size of the list.


Ralph Schoon commented Jan 02 '13, 9:01 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you haven't found examples already, here a small introduction on how to get at work item attributes in the Java API. http://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

One other answer



permanent link
Dinesh Kumar B (4.1k413) | answered Dec 28 '12, 9:27 a.m.
JAZZ DEVELOPER
you could use getValue with attribute id specified within double quotes

sample code:
var custAttr = workItem.getValue("custAttrID");
hope it helps

Comments
Ralph Schoon commented Dec 28 '12, 10:58 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

This is of course the syntax if using a script based customization. Since the question fails to give enough context, it is unclear if that is the question. This blog answers this question for the plain java client library and other extensions as well.


Dnyanesh Markad commented Dec 31 '12, 7:41 a.m.

Hi,

In deatail, suppose I have one custom attribute as custA. Its type is medium string. In editor presentations I have assigned the attribute values as list. So now I want to get the number of selected attributes in the list programatically. 

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.