It's all about the answers!

Ask a question

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


Anurag Patel (216) | asked Nov 11 '16, 12:58 a.m.
edited Nov 11 '16, 2:09 a.m. by Ralph Schoon (55.6k23642)
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


permanent link
Ralph Schoon (55.6k23642) | answered Nov 11 '16, 2:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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

linkWorkItemsCLM 

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

Ralph Schoon selected this answer as the correct answer

Comments
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 (216) | 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);
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.

Comments
Ralph Schoon commented Nov 14 '16, 2:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


permanent link
Ralph Schoon (55.6k23642) | answered Nov 12 '16, 10:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.