It's all about the answers!

Ask a question

How to set Attributes of an RTC Work Item programatically


Vaibhav S (9619) | asked Oct 06, 8:56 a.m.
edited Oct 06, 8:59 a.m.

Hello Ralf,


I found this code from your old articles for setting the attributes of an RTC Work Item:
IWorkItemClient workItemClient= (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
           
            IAttribute attribute = workItemClient.findAttribute(workItem.getProjectArea(),
                    fAttributeID, monitor);
            if(null!=attribute){
                if(workItem.hasAttribute(attribute))
                    workItem.setValue(attribute, fValue);
            }

Here i get an Error that Work Item is Immutable. Can you please help me as to how to make the Work Item object Mutable so i can Set Attributes to it.

Thanks!
Vaibhav 

Accepted answer


permanent link
Ralph Schoon (58.9k23642) | answered Oct 06, 9:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 You have to use a work item working copy and a WorkitemOperation.

See https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/  - you can search for WorkitemOperation. There are numerous examples on that blog, with downloadable code, that you could look at. https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation is the original source. WorkitemOperation is the way to do it.

Vaibhav S selected this answer as the correct answer

Comments
Vaibhav S commented Oct 13, 11:12 a.m.

Hi Ralf, 


Thanks for the response. 

I am able to edit String Type Attributes now.

For Enum type Attributes i referred your code from article: https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/

For some reason i get Error as: "ASSEERTION FAILED".

Can you please help me with how to solve this issue.

Thanks!
Vaibhav

 


Ralph Schoon commented 2 days ago
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

No, you do not provide any actionable information.

Assertion Failed is typical for passing an invalid value. I would suggest you use the Eclipse debugging capabilities to find out where this happens and what the data is. The RTC Extensions Workshop describes how to set up an RTC/EWM development environment that allows debugging of the Plain Java Client Libraries. It is pretty much the same information that is up on my blog since 8 years, just a bit more organized. Good luck. 

Your answer


Register or to post your answer.