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

how to create workitems with custom attributes using plain java client

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?

0 votes


Accepted answer

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

2 votes

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,927

Question asked: Dec 03 '13, 9:05 a.m.

Question was seen: 3,592 times

Last updated: Dec 03 '13, 9:52 a.m.

Confirmation Cancel Confirm