RTC Plain Java API, How to refresh/refetch a workitem as it is throwing MultiStaleDataException
hi Team,
We are trying to attach a workitem to the main workitem and then close the main workitem. On Closing the main workitem, API is throwing MultiStaleDataException : Stale Data
IWorkItem workItem = workItemClient.findWorkItemById(workItem1.getId(), IWorkItem.FULL_PROFILE, null);
is not fetching the fresh copy of the workitem.
Following is the code for the same :
IWorkItemWorkingCopyManager copyManager = null;
IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
copyManager = workItemClient.getWorkItemWorkingCopyManager();
copyManager.connect(workItem1, IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy wc = copyManager.getWorkingCopy(workItem1);
IWorkItem workItemWorkItemCopy = wc.getWorkItem();
copyManager.save(new WorkItemWorkingCopy[] { wc }, monitor);
copyManager.disconnect(workItem1);
One answer
You should use a WorkitemOperation to update work items. See https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ and search for WorkItem Operation.
https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/ explains how to create links between work items.
Also see https://rsjazz.wordpress.com/2013/11/06/creating-clm-links-with-back-link/ how to get the backlink created.