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

Programmatically adding a comment to a work item

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.

0 votes



9 answers

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

0 votes


Permanent link
Thanks for replying.

Which example might you be referring to?

0 votes


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

0 votes


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

0 votes


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

0 votes


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

0 votes


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

0 votes


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

0 votes

Comments

Hi Patrick,

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

From where do I import these?

Thanks.


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

0 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,952

Question asked: Dec 04 '08, 1:18 p.m.

Question was seen: 15,444 times

Last updated: Aug 27 '12, 3:16 p.m.

Confirmation Cancel Confirm