It's all about the answers!

Ask a question

how to create workitems with custom attributes using plain java client


Piotr Aniola (3.7k11738) | asked Dec 03 '13, 9:05 a.m.
Hello,

I'm using the following article to create workitems from Plain Java Client:
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

It all works, but I would like to set some custom attributes during workitem creation. Let's assume I have the attribute name and ID. How can I do it?

Accepted answer


permanent link
Kevin Ramer (4.5k9185200) | answered Dec 03 '13, 9:52 a.m.
There is an api call that will give you a list of custom attributes.

List<IAttributeHandle> customAttributes = workItem.getCustomAttributes();

Then just iterate over that list and handle the ones you need.

                        for (IAttributeHandle attributeHandle : customAttributes) {
                                IAttribute attribute = (IAttribute) jazzServer
                                                .getRepository()
                                                .itemManager()
                                                .fetchCompleteItem(attributeHandle,
                                                                IItemManager.DEFAULT, jazzServer.getMonitor());
                                                                                + attribute.getIdentifier());
                                if (attribute.getIdentifier().equals("justification")) {
                                               workItem.setValue(attribute,some_value);
                                  ......
                      }
The IAttribute fetchCompleteItem call gets the attribute, then you can get the id (getIdentifier()) and set the attribute.
 
Piotr Aniola selected this answer as the correct answer

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.