It's all about the answers!

Ask a question

Add multiple references to the work item at same time using server api

Anurag Patel (21363) | asked Nov 11 '16, 12:58 a.m.
edited Nov 11 '16, 2:09 a.m. by Ralph Schoon (63.1k33646)

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 ));


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

permanent link
Ralph Schoon (63.1k33646) | answered Nov 11 '16, 2:23 a.m.
Yes, you can. See method


You can add multiple references and save them with saveWorkItem3()

Ralph Schoon selected this answer as the correct answer

Anurag Patel commented Nov 12 '16, 12:46 a.m.

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

permanent link
Anurag Patel (21363) | answered Nov 12 '16, 7:06 a.m.
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);

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.

Ralph Schoon commented Nov 14 '16, 2:22 a.m.

 I answered that this is to be expected and why below.

permanent link
Ralph Schoon (63.1k33646) | answered Nov 12 '16, 10:24 a.m.
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.

Your answer

Register or 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.