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

How I add new comment for WorkItem using Server Side Plugin

 Hi all,

I need a some help. I have an advisor plugin in RTC. I want to add new comment my source workitem.

My code: 
IComments comments = sourceworkItem.getComments(); 
IContributorHandle creator = contributorService.fetchContributorByUserId("JAZZDEVADM");
String commentString = "content content some content";
XMLString content = XMLString.createFromPlainText(commentString);
IComment comment = (IComment) comments.createComment(creator, content);
comments.append(comment);
But i get this error: 
Error running operation 'Saving Work Item'
Validation errors for item: type = WorkItem, itemId = [UUID _L2jbAIaJEeSkQJKbbjlvNg]
Required property must not be null: internalComments.creationDate
Validation errors for item: type = WorkItem, itemId = [UUID _L2jbAIaJEeSkQJKbbjlvNg]
Required property must not be null: internalComments.creationDate
Why this happen? How i can set creationDate? 

1 vote


Accepted answer

Permanent link

Hi all,
I'd like to share how I did!

The comments aren't a attribute, but a collection.

                    IComments comments = workItem.getComments();
                    Comment  newComment = (Comment) comments
                            .createComment(
                             workItem.getCreator(),
                             XMLString.createFromPlainText("write your comment here"));               


                   //You have to set a creation date, required.
                   Timestamp now = new Timestamp(System.currentTimeMillis());                    
                   newComment.setCreationDate(now);                                                                                    
                   comments.append(newComment);        

          
                   //if you want to see your comments list.
                   IComment[] contents = comments.getContents();
                   for (IComment iComment : contents) {
                       System.out.println(iComment.getHTMLContent());
                   }
                    
Hope I can help anybody else, if you like it let a thumbs up!                   

Ralph Schoon selected this answer as the correct answer

0 votes


2 other answers

Permanent link
Hello Hakki.

Are you creating a workitem that same advisor? The workitem must have a "creation date".

Try:
sourceworkItem.setCreationDate(<Timestamp>);

PS: Insert the code above before the comment creation.

0 votes

Comments

 Hello Pietro,

that creationdate not workitem creationdate, is comment creationdate. 
i am trying a new comment for existing workitem.


Permanent link
Hi all,

I found my answer, IComment setCreationDate not have setCreationDate so, i add cast "Comment". Its work.
 
((Comment)comment).setCreationDate(now); 

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,937
× 70
× 27

Question asked: Nov 25 '15, 9:35 a.m.

Question was seen: 4,844 times

Last updated: Oct 29 '23, 8:06 p.m.

Confirmation Cancel Confirm