How to get a workitem by id in TFS 2013 web access when writing custom controls?

751 views Asked by At

I have built an incomplete extension for TFS Webaccess 2013 in javascript. I want to modify combobox input based on linked work item types. For instance - User Story 555 is currently in active state, and I would like to prevent users from changing to a closed state by greying out the option in the combobox IF a linked child element is still active. I can grey out the item, but I cannot figure out how to get the state of the linked child workitem.

I'm able to say the following in javascript to get the ID of the first linked workitem:

var itemID = workitem.allLinks[0].linkData.ID;

I'm calling this within the bind() function, where workitem is passed as a parameter. I need the ability to grab the state of the child workitem, but have been unsuccessful so far. Please help.

1

There are 1 answers

0
Serkan Inci On

First of all, please use

workItem.getLinks()

instead of allLinks since all links may include removed links as well.

Then you can access a work item by id using following async call:

workItem.store.beginGetWorkItem(linkedWorkItemId, function(linkedWorkItem) {
    var state = linkedWorkItem.getFieldValue("System.State");
    // Use state here..
});