4

I am new to Azure DevOps Extensions. Not sure what I am doing wrong here but I cannot get certain fields for work items returned by the getWorkItems REST API.

I have tried everything I can find on the message boards and still cannot get certain specified fields to return in the results.

You can see the fields array below to see the specific fields I am trying to get back with the results.

Here are the fields that I can't seem to get returned in the results

"Microsoft.VSTS.Scheduling.StartDate"
"Microsoft.VSTS.Scheduling.StoryPoints"
"Microsoft.VSTS.Scheduling.TargetDate"
"System.AssignedTo"
"Microsoft.VSTS.Scheduling.CompletedWork"

     VSS.require(["VSS/Service", "TFS/WorkItemTracking/RestClient"],
        function (VSS_Service, TFS_Wit_WebApi) {
            // Get the REST client
            var witClient = VSS_Service.getCollectionClient(TFS_Wit_WebApi.WorkItemTrackingHttpClient);

            var fields = ["System.Id", "Microsoft.VSTS.Scheduling.StartDate", "Microsoft.VSTS.Scheduling.StoryPoints", "Microsoft.VSTS.Scheduling.TargetDate", "System.WorkItemType", "System.Title", "System.AssignedTo", "System.State", "System.Tags", "Microsoft.VSTS.Scheduling.CompletedWork", "System.Description", "Microsoft.VSTS.Scheduling.FinishDate"];
            var ids = [workItemID];

            witClient.getWorkItems(ids, fields).then( 
            function(result) {
                document.getElementById("codeblock").innerText = JSON.stringify(result);

            });

        });

Here is the JSON that is returned


    [{
        "id": 7743,
        "rev": 3,
        "fields": {
            "System.Id": 1234,
            "System.WorkItemType": "Feature",
            "System.State": "Closed",
            "System.Title": "Sprint 39 - Technical"
        },
        "url": "https://<companyurl>/_apis/wit/workItems/1234"
    }]

I have even tried the ExpandAll optional parameter in the getWorkItems call and those fields are not returned with the results.

i.e:


    witClient.getWorkItems(ids, undefined, undefined, ["All"]).then( 
            function(result) {

I am stumped, any help or direction on where to look to find these values would be very helpful and appreciated.

  • 1
    Have you tried specifying the integer for the All enum as mentioned on this [answer](https://stackoverflow.com/a/50284267/10761889) – Matt Mar 25 '19 at 21:37
  • I just tried that (thanks for the suggestion) and still get the same results. a bunch of fields are returned, but not the ones I am looking for stated above in the original post, which are part of the work items in Azure DevOps. – Jack Phillips Mar 25 '19 at 23:44

1 Answers1

0

I figured out what I was doing wrong. In the vss-extension.json extension manifest file there is a section for scopes. I had to change the scope from "vso.work" to "vso.work_full" and that did the trick. I am now able to get all the fields for the work items

"scopes": ["vso.work"],

To

"scopes": ["vso.work_full"],