It's all about the answers!

Ask a question

Programmatically adding a comment to a work item


Brandon McMillon (61) | asked Dec 04 '08, 1:18 p.m.
My goal is to add a comment programatically using the plain Java SDK. The API for work items doesn't immediately make this apparent. I've scoured over the RtcSdk wiki. And it is ripe with creating new work items. However, I'm stuck not seeing how to add a comment.

9 answers



permanent link
derek cheng (46121) | answered Dec 04 '08, 2:05 p.m.
My goal is to add a comment programatically using the plain Java SDK. The API for work items doesn't immediately make this apparent. I've scoured over the RtcSdk wiki. And it is ripe with creating new work items. However, I'm stuck not seeing how to add a comment.


workItem.setHTMLDescription(XMLString.createFromPlainText(fDescription));

The plain java code example covers the rest.

permanent link
Brandon McMillon (61) | answered Dec 04 '08, 3:03 p.m.
Thanks for replying.

Which example might you be referring to?

permanent link
derek cheng (46121) | answered Dec 04 '08, 4:09 p.m.
Thanks for replying.

Which example might you be referring to?

No problem!

https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation
Plain-Java Client

The WorkItemInitialization class does most of the work. You can set whatever fields you need inside the execute field.

permanent link
Patrick Streule (4.9k21) | answered Dec 05 '08, 3:38 a.m.
JAZZ DEVELOPER
A snippet that adds as comment to a work item:

IComments comments= workingCopy.getComments();
IComment comment= comments.createComment(authenticatedUser,
getText(commentString));
comments.append(comment);

--
Regards,
Patrick
Jazz Work Item Team

permanent link
jmilam (111) | answered Jan 15 '09, 8:49 p.m.
When trying to create a comment using the following code

IWorkItem workingCopy = workItemClient.findWorkItemById(456, IWorkItem.FULL_PROFILE, null);

IComments comments= workingCopy.getComments();
IComment comment= comments.createComment( teamRepository.loggedInContributor(),
XMLString.createFromPlainText( "This is my new commend from the java api"));
comments.append(comment);


I get an com.ibm.team.repository.common.internal.ImmutablePropertyException being thrown by
comments.append(comment);
any pointers?

permanent link
Kinny Kun (5183) | answered Feb 18 '09, 6:17 p.m.
I'm getting the same error. Any idea what may cause the error? Please help.

Thanks!

When trying to create a comment using the following code

IWorkItem workingCopy = workItemClient.findWorkItemById(456, IWorkItem.FULL_PROFILE, null);

IComments comments= workingCopy.getComments();
IComment comment= comments.createComment( teamRepository.loggedInContributor(),
XMLString.createFromPlainText( "This is my new commend from the java api"));
comments.append(comment);


I get an com.ibm.team.repository.common.internal.ImmutablePropertyException being thrown by
comments.append(comment);
any pointers?

permanent link
Kinny Kun (5183) | answered Feb 18 '09, 6:19 p.m.
I'm getting the same error. Any idea what may cause the error? Please help.

Thanks!

When trying to create a comment using the following code

IWorkItem workingCopy = workItemClient.findWorkItemById(456, IWorkItem.FULL_PROFILE, null);

IComments comments= workingCopy.getComments();
IComment comment= comments.createComment( teamRepository.loggedInContributor(),
XMLString.createFromPlainText( "This is my new commend from the java api"));
comments.append(comment);


I get an com.ibm.team.repository.common.internal.ImmutablePropertyException being thrown by
comments.append(comment);
any pointers?

permanent link
Patrick Streule (4.9k21) | answered Feb 19 '09, 9:08 a.m.
JAZZ DEVELOPER
I'm getting the same error. Any idea what may cause the error? Please
help.

I get an
com.ibm.team.repository.common.internal.ImmutablePropertyException
being thrown by

You can't modify the work item itself, you need to modify a working copy:

IWorkItemWorkingCopyManager workingCopyManager=
workItemClient.getWorkItemWorkingCopyManager();
workingCopyManager.connect(handle, ...);
WorkItemWorkingCopy workingCopy=
workingCopyManager.getWorkingCopy(handle);


// modify work item
IWorkItem workItem= workingCopy.getWorkItem();
...

workingCopy.save(null);

--
Regards,
Patrick
Jazz Work Item Team

Comments
Ananya Joisa commented Aug 27 '12, 3:16 p.m.

Hi Patrick,

I am getting a cannot resolve error for IWorkItemWorkingCopyManager, workItemClient etc.

From where do I import these?

Thanks.


permanent link
Kinny Kun (5183) | answered Feb 19 '09, 2:57 p.m.
I'm able to modify the working copy now. Thanks alot for the help. Really appreciated! Thanks.


I'm getting the same error. Any idea what may cause the error? Please
help.

I get an
com.ibm.team.repository.common.internal.ImmutablePropertyException
being thrown by

You can't modify the work item itself, you need to modify a working copy:

IWorkItemWorkingCopyManager workingCopyManager=
workItemClient.getWorkItemWorkingCopyManager();
workingCopyManager.connect(handle, ...);
WorkItemWorkingCopy workingCopy=
workingCopyManager.getWorkingCopy(handle);


// modify work item
IWorkItem workItem= workingCopy.getWorkItem();
...

workingCopy.save(null);

--
Regards,
Patrick
Jazz Work Item Team

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.