appending Comments during an initial programmatic create
![]()
I am programmatically creating work items and I am having issues doing comments. The code does this:
//get a "working copy" of an empty work item final IWorkItemType workItemType = workItemClient.findWorkItemType (projArea, "defect", null); final IWorkItemHandle handle = workItemClient.getWorkItemWorkingCopyManager().connectNew (workItemType, null); final WorkItemWorkingCopy workingCopy = workItemClient.getWorkItemWorkingCopyManager ().getWorkingCopy (handle); final IWorkItem workItem = workingCopy.getWorkItem (); //fill in all the values . //Description XMLString description = XMLString.createFromPlainText(descriptionText); workItem.setHTMLDescription (description); . //add the comments IComments srcComments = workItem.getComments(); XMLString content = XMLString.createFromPlainText(contentString); IComment ic = srcComments.createComment(creator , content); srcComments.append(ic); //workItem.setValue(comment,srcComments); //save to create it final IDetailedStatus status = workingCopy.save (null); Now, I was trying the setValue() at the end but that gave a classCastException, so I removed it. My code runs and the description shows up in the new work item, but no comments. The description uses setHTMLDescription() but I didn't find a "setComments() or setHTMLComments(). Has anyone done this? Can you send a snippet or tell me what I am doing wrong?? Thanks in advance, susan |
Accepted answer
One other answer
![]()
Hi,
try this method. WorkItem.getComments.append(IComment); This IComment parameter you can create by WorkItem.getComment.CreateComment(); method. Regards Muthukumar.C |