How to get the custom attributes programatically?
Accepted answer
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
Comments
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
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.
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
sample code:
var custAttr = workItem.getValue("custAttrID");hope it helps
Comments
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.
Hi,