VSTS仪表板小部件getWorkItem可选参数展开 [英] VSTS Dashboard Widget getWorkItem optional parameter expand
问题描述
However I am running into a problem when using the getWorkItem() function. I want to get the ids of all the Features under a given Epic (I already know the epic ID). I am confident that if I set the expand paremeter of getWorkItem() to "All" I will get a list of all the Features and their respective ids. Unfortunately I do not know how to define the "type" of expand parameter and how to properly pass it as a value to the getWorkItem() function.
这是我的代码:
VSS.require(["VSS/Service", "TFS/Dashboards/WidgetHelpers", "TFS/WorkItemTracking/RestClient"],
function (VSS_Service, WidgetHelpers, TFS_Wit_WebApi) {
WidgetHelpers.IncludeWidgetStyles();
VSS.register("myapp", function () {
var fetchData = function (widgetSettings) {
const epicID = 123456;
// Get a WIT client to make REST calls to VSTS
return VSS_Service.getCollectionClient(TFS_Wit_WebApi.WorkItemTrackingHttpClient).getWorkItem(123456, null, null, All).
then(
//Successful retrieval of workItems
function (workItems) {
$('#myText').text(JSON.stringify(workItems));
console.log(workItems);
// Use the widget helper and return success as Widget Status
return WidgetHelpers.WidgetStatusHelper.Success();
},
function (error) {
// Use the widget helper and return failure as Widget Status
return WidgetHelpers.WidgetStatusHelper.Failure(error.message);
});
}
这是展开 它说明了值可以是什么,但没有说明如何将其传递给getWorkItem()函数.
Here is the VSTS reference for expand It explains what the values can be, but doesn't say how to pass it into the getWorkItem() function.
我想将函数的可选扩展参数设置为全部",但不知道其类型以及如何正确定义和使用它.
I would like to set the optional expand parameter of the function to "All" but don't know its type and how to properly define and use it.
推荐答案
Based on the source code, it is the enum, so you can specify the integer (e.g. 4) in getWorkItem function.
export enum WorkItemExpand {
None = 0,
Relations = 1,
Fields = 2,
Links = 3,
All = 4,
}
这篇关于VSTS仪表板小部件getWorkItem可选参数展开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!