It's all about the answers!

Ask a question

How I add new comment for WorkItem using Server Side Plugin


Hakki Bozkurt (1631227) | asked Nov 25 '15, 9:35 a.m.
 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? 

2 answers



permanent link
Pietro Bottino (35614) | answered Nov 25 '15, 1:24 p.m.
edited Nov 25 '15, 1:28 p.m.
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.

Comments
Hakki Bozkurt commented Nov 25 '15, 1:48 p.m.

 Hello Pietro,

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


permanent link
Hakki Bozkurt (1631227) | answered Nov 25 '15, 1:51 p.m.
Hi all,

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

Your answer


Register or to post your answer.