It's all about the answers!

Ask a question

How to force a Save operation when only changing links in a work item using java plain client?

Todd Mueller (131) | asked Aug 10 '22, 5:58 p.m.
I am writing a java plain client utility that attempts to force modify a work item, specifically by removing an existing parent link, and then re-adding it.  I'm doing this because I also have a couple of server preconditions/followup actions that will run on a Save Operation that is specifically looking for a change in work item links.  However, my utility program is "working" in that it removes and re-adds the parent link, but this does NOT kick off the server-side preconditions/followup actions. It appears this only works on a java plain client program if it actually updates a work item attribute value.  I know, links are a separate entity inside EWM's database.  Side note, using the web UI or the rich client, the act of (e.g.) removing a parent link and clicking Save DOES kick off the server preconditions/followup actions where it does detect the change in links (via ISaveParameter.getNewReferences()).

In the utility, I'm using ILinkManager to deleteLink() and saveLink().  However, this does not trigger a Save Operation on the work item.  Therefore, is there another API I can call to simulate a Save Operation (that also detects the link changes)?

Accepted answer

permanent link
Ralph Schoon (62.0k33643) | answered Aug 11 '22, 2:32 a.m.
edited Aug 11 '22, 4:47 a.m.
  1. This here describes how you operate with work item: . The best way to update a work item is to use a work item operation as in the examples.
  2. I am not sure what ILinkManager does, but it does not save links on a work item.  
  3. The code below is used to add a new link to the work items references the implementation uses a work item operation. If you use other methods make sure to use the work item save method that also saves the references. A working copy only has saver(monitor) the Server API has other save2 and save 3 and only the latter saves the references.  
    // Linking Blocking
    private static class LinkBlockingWorkItemOperation extends
            WorkItemOperation {

        private IWorkItemHandle fOpposite;

        public LinkBlockingWorkItemOperation(IWorkItemHandle opposite) {
            super("Linking Blocking Work Item", IWorkItem.FULL_PROFILE);
            fOpposite = opposite;

        protected void execute(WorkItemWorkingCopy workingCopy,
                IProgressMonitor monitor) throws TeamRepositoryException {
            IItemReference reference = IReferenceFactory.INSTANCE


Todd Mueller selected this answer as the correct answer

Ralph Schoon commented Aug 11 '22, 2:44 a.m.

Please also note, that the operation behavior is only triggered for work item links (like parent/child) but not for CLM links that work across servers e.g. Tracks/Contributes to. 

Todd Mueller commented Aug 11 '22, 5:17 p.m.

Thank you Ralph. I am using the WorkItemOperation way of updating the work item.  It was inside the execute() method here where I had the code to update a work item attribute value, AND used the ILinkManager to remove/add the link.  I believe you're right in that this does not directly do things through the work item itself.  I'll play with trying to modify the links on a work item through the work item references as you suggest.

Ralph Schoon commented Aug 12 '22, 4:36 a.m. | edited Aug 12 '22, 4:36 a.m.
You have to remove references like this:


You might also have to add: 


Todd Mueller commented Aug 16 '22, 1:27 a.m.

Thank you Ralph.  You were correct in my scenario that I needed to use the work item's references (workingCopy.getReferences()) for removing and adding the parent link instead of using ILinkManager.  This solution causes a perceived change on the work item itself, which then kicks off all my preconditions and followup actions, which is the behavior I wanted. Got it working now.

Your answer

Register or to post your answer.