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

Attempting to add comment to work item - comments are not added

 I've created a groovy framework that accesses the Java Plain API, and I've been successful in all aspects of manipulating work items, build definitions, and source control except for one: adding comments to work items. 

Here is the function in question:

    
    def addCommentToWorkItem(String workItemId, String commentText, monitor=null) {
            IContributor currentLoggedInContributor = repo.loggedInContributor();

            IWorkItemClient wcl = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
            IWorkItemWorkingCopyManager wcManager = wcl.getWorkItemWorkingCopyManager();
            IWorkItem wi = (IWorkItem) wcl.findWorkItemById(Integer.parseInt(workItemId), IWorkItem.FULL_PROFILE, monitor);
            wcManager.connect(wi, IWorkItem.FULL_PROFILE, monitor);

            WorkItemWorkingCopy wiCopy = wcManager.getWorkingCopy(wi);
            wi = wiCopy.getWorkItem();
            // If the text contains links, add <a href="link">link text</a> in the text and use XMLString.createFromXMLText
            // IComment comment = wi.getComments().createComment(currentLoggedInContributor, XMLString.createFromXMLText("Testing comment at " + System.currentTimeMillis() + "<a href=\"https://jazz.net\">jazz.net</a>"));
            IComment comment = wi.getComments().createComment(currentLoggedInContributor, XMLString.createFromXMLText(commentText));
            wi.getComments().append(comment);
            wiCopy.save(monitor);
            wcManager.disconnect(wi);
    }

But even if I append comments to a working item copy and save that working item copy, I don't see any comments added to the work item.  Am I missing something here?


1

0 votes



One answer

Permanent link

 

You should use a workitem operation

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,938
× 31
× 6

Question asked: May 10 '21, 3:29 p.m.

Question was seen: 3,093 times

Last updated: May 11 '21, 2:21 a.m.

Confirmation Cancel Confirm