Add multiple references to the work item at same time using server api
Hi,
I am trying to add the list of work item as a "Tracks" link in parent work item. I had written below code for that.
for (IWorkItem workItem : workItemList) {
referencesTask = workItemServer.resolveWorkItemReferences(parentWorkItem, monitor);
referencesTask.add(WorkItemEndPoints.TRACKS_BY_ITEMS,WorkItemLinkTypes.createWorkItemReference(workItem ));
saveWorkitem(parentWorkItem,saveParameter,workItemServer,referencesTask);
}
Currently I creating reference of existing work item with parent work item of link type "Tracks" this is creating reference one by one by calling save operation. Is there any way to do it on only by calling one save operation.
Please provide useful link for above.
Accepted answer
Yes, you can. See https://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/ method
You can add multiple references and save them with saveWorkItem3()
linkWorkItemsCLM
You can add multiple references and save them with saveWorkItem3()
Comments
Hi Ralph,
Thanks for the reply.
I go through above mentioned link and I was able to link multiple references of work item but when I tried to save the work item then at a single save operation I can able to save only link at a one save operation. Suppose if I added 5 links then for each loop I have to call save operation. Is there any way to save all links on by calling single save operation in code. Due to multiple save operation it decrease performance.
2 other answers
Hi Ralph,
I created custom follow up plugin to read the children of workitem and create the "Track" type of link for all the children workitem in same parent workitem by following logic :
IWorkItemReferences referencesTask = null;
for (IWorkItem workItemTrackTo : workItemList) {
referencesTask = workItemServer.resolveWorkItemReferences(disciplineWorkItem, monitor);
referencesTask.add(WorkItemEndPoints.TRACKS_BY_ITEMS,WorkItemLinkTypes.createWorkItemReference(workItemTrackTo));
saveWorkitem(disciplineWorkItem,saveParameter,workItemServer,referencesTask);
}
Implemented above logic to create track of a children workitem with a parent workitem.
This logic is working fine but issue is that in browser if we change the tab in work item then it will show notification to "Refresh to get the latest updates" every time for parent work item.
Do you have any idea about why this is show notification to every time when click on other tab in browser.
Does your prticipant create a new link? Does creating the link be a change to the work item open in the browser? Would this change be detected eventually in the browser?
For all I know the the participant changes the work item without notifyng the work item open in the browser. The browser will detect the change eventually however and tell you to refresh. You could even wait with the work item open in the browser for some time without changing the tab and the message would come up like it does if someone else changes the work item in another browser window. so I think this behavior is to be expected.
For all I know the the participant changes the work item without notifyng the work item open in the browser. The browser will detect the change eventually however and tell you to refresh. You could even wait with the work item open in the browser for some time without changing the tab and the message would come up like it does if someone else changes the work item in another browser window. so I think this behavior is to be expected.