Setting "Discussion" attribute of Work Item
Hello,
I am trying to set the value of "Discussion" at work item pragmatically.
IWorkItemClient workItemClient= (IWorkItemClient)repository.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager manager= workItemClient.getWorkItemWorkingCopyManager();
manager.connect(workItem, IWorkItem.SMALL_PROFILE, SysoutProgressMonitor.getMonitor());
WorkItemWorkingCopy wc= manager.getWorkingCopy(workItem);
IProgressMonitor monitor = SysoutProgressMonitor.getMonitor();
IWorkItemClient service = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);
IAttribute discussionAttribute = service.findAttribute(projectArea, "discussion", monitor);//Here I got a null "discussionAttribute"?
I managed to set the "Description" attribute but when I tried to set the Discussion I got null pointer exception :
IWorkItemWorkingCopyManager manager= workItemClient.getWorkItemWorkingCopyManager();
manager.connect(workItem, IWorkItem.SMALL_PROFILE, SysoutProgressMonitor.getMonitor());
WorkItemWorkingCopy wc= manager.getWorkingCopy(workItem);
IProgressMonitor monitor = SysoutProgressMonitor.getMonitor();
IWorkItemClient service = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);
IAttribute discussionAttribute = service.findAttribute(projectArea, "discussion", monitor);//Here I got a null "discussionAttribute"?
wc.getWorkItem().setValue(discussionAttribute, "New Value for Discussion");
Any ideas!
Accepted answer
yeh, its id is "internalComments".. don't know why it doesn't respond to Comments
see my sample dump all attributes code here , second post
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
see my sample dump all attributes code here , second post
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
Comments
showing 5 of 6
show 1 more comments
4 other answers
for the 'how', download the java doc
the xml - I edited the process config, and found the comments attribute
there is no 'discussion' attribute.. (at least not in the out of the box objects) if it is a custom object, then you would have to use the 'id' value
the xml - I edited the process config, and found the comments attribute
there is no 'discussion' attribute.. (at least not in the out of the box objects) if it is a custom object, then you would have to use the 'id' value
Comments
This is the final resolution and it works :)
Thanks to Sam.
IWorkItemClient workItemClient= (IWorkItemClient)repository.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager manager= workItemClient.getWorkItemWorkingCopyManager();
manager.connect(workItem, IWorkItem.SMALL_PROFILE, SysoutProgressMonitor.getMonitor());
WorkItemWorkingCopy wc= manager.getWorkingCopy(workItem);
IAttribute commentsAttr = findAttribute(repository, projectArea, "internalComments");
IComments comments= wc.getWorkItem().getComments();
IComment comment= comments.createComment( repository.loggedInContributor(),
XMLString.createFromPlainText( "Aloo from Mars"));
comments.append(comment);
wc.save(null);