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

RTC Plain JAVA API To open an existing defect and update a field

Hi
 I am trying to update an existing defect.
What I want to do is search for a defect open it and update a field like summary.
To search a defect I have the following code what I cant do is update the defect.


public static IWorkItem getWorkItem()
    throws TeamRepositoryException, FileNotFoundException,
    ParseException {

        // Set the connection
        String repositoryURI = getHost(env);
       
        // Start the platform.
        TeamPlatform.startup();
       
        ITeamRepository teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
        teamRepository.registerLoginHandler(new LoginHandler(userName, userPass));
        teamRepository.login(null);
        IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
       
            IProgressMonitor progressMonitor = new NullProgressMonitor();
            ItemProfile<IWorkItem> arg1 = IWorkItem.FULL_PROFILE;
            IWorkItem foundId  = workItemClient.findWorkItemById(119049, arg1, progressMonitor);
       
              System.out.println("found me"+foundId.getId());
              System.out.println("found me"+foundId.getHTMLSummary().getPlainText());
              System.out.println("found me"+foundId.getHTMLDescription().getPlainText());

        teamRepository.logout();
        TeamPlatform.shutdown();
        return foundId;
}




Any suggestion are welcome
Thanks
MrCoolK


0 votes


Accepted answer

Permanent link
RTC has two views of a workitem.. the readonly copy (given out be default) and the read/write version, called the workingcopy.

so, once you find the handle, you get the workitem (read only), IWorkItem foundId above
then get the read/write version (getworkingcopy) IWorkItem foundid_rw = foundid.getworkingcopy();

you update the fields in the workingcopy, then Save the working copy.


kishan adhi selected this answer as the correct answer

1 vote

Comments

Thank you very much for the answer.It worked

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

Question asked: May 01 '13, 3:02 p.m.

Question was seen: 3,866 times

Last updated: May 02 '13, 3:54 p.m.

Confirmation Cancel Confirm