我是一个总菜鸟,并且一直试图将VSTS工作项字段值添加到我的VSTS扩展中并且一直在遇到问题。每当我在浏览器中加载扩展程序时,都会收到以下错误消息:
No handler found on any channel for message: {"id":2,"methodName":null,"instanceId":"sample-extension-page","instanceContext":{[RETRACTED]},"params":null,"jsonrpc":"2.0"}
我已经浏览过互联网,但未能找出我的问题所在。我只想传递System.Id和System.Title的活动Work Item字段值,以便我可以在我的扩展页面/表单上显示它们。任何帮助将不胜感激,谢谢!
我的html页面中的脚本:
<script type="text/javascript">
console.log("VSS Initialize...");
VSS.init({
usePlatformScripts: true,
explicitNotifyLoaded: true,
usePlatformStyles: true,
configureModuleLoader:true
});
console.log("VSS Ready.");
VSS.ready(function(){
console.log("VSS REQUIRE");
VSS.require(["TFS/WorkItemTracking/Services"], function(_WorkItemServices) {
console.log("Inside VSS REQUIRE.");
// Get the WorkItemFormService. This service allows you to get/set fields/links on the 'active' work item (the work item
// that currently is displayed in the UI).
console.log("GET WORK ITEM FORM SERVICE");
function getWorkItemFormService(){
console.log("Inside GET WORK ITEM FORM SERVICE!");
return _WorkItemServices.WorkItemFormService.getService();
}
// VSS.register(VSS.getContribution().id, function(){
console.log("VSS REGISTER.");
console.log("VSS Contribution ID === " + VSS.getContribution().id);
VSS.register(VSS.getContribution().id, function(){
console.log("Inside VSS REGISTER");
return {
// Called when the active work item is modified
onFieldChanged: function(args) {
$(".events").append($("<div/>").text("onFieldChanged - " + JSON.stringify(args)));
},
// Called when a new work item is being loaded in the UI
onLoaded: function(args){
console.log("onloaded");
getWorkItemFormService().then(function(service) {
service.getFieldValues(["System.Id","System.Title"]).then(function(value){
$(".events").append($("<div/>").text("onLoaded - " + JSON.stringify(value)));
console.log("WORK ITEM VALUES : " + JSON.stringify(value));
});
});
},
// Called when the active work item is being unloaded in the UI
onUnloaded: function(args) {
console.log("onunloaded.");
$(".events").empty();
$(".events").append($("<div/>").text("onUnloaded - " + JSON.stringify(args)));
},
// Called after the work item has been saved
onSaved: function (args) {
$(".events").append($("<div/>").text("onSaved - " + JSON.stringify(args)));
},
// Called when the work item is reset to its unmodified state (undo)
onReset: function (args) {
$(".events").append($("<div/>").text("onReset - " + JSON.stringify(args)));
},
// Called when the work item has been refreshed from the server
onRefreshed: function (args) {
$(".events").append($("<div/>").text("onRefreshed - " + JSON.stringify(args)));
}
}
});
});
});
vss-extension.json文件:
{
"manifestVersion": 1,
"id": "sample-extension",
"version": "0.1.64",
"name": "sampleextension",
"displayName":"Sample Extension",
"description": "Sample Extension",
"publisher": "[RETRACTED]",
"contentType":"application/json",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"icons": {
"default": "images/icon.png"
},
"contributions": [
{
"id": "sample-extension-page",
"type": "ms.vss-work-web.work-item-form-page",
"description": "Sample extenion page",
"targets": [
"ms.vss-work-web.work-item-form"
],
"properties": {
"name": "sample-extenion-page",
"uri": "hello-world.html"
}
}
],
"scopes": [
"vso.work"
],
"files": [
{
"path": "scripts", "addressable": true
},
{
"path": "sdk/scripts", "addressable": true
},
{
"path": "images/icon.png", "addressable": true
},
{
"path":"hello-world.html","addressable":true
}
]
}
答案 0 :(得分:2)
我有一个类似的问题...但这是用户错误。我在我的配置页面上注册了此代码:
VSS.register("HelloWorldWidget.Configuration", function () {
然后我的清单上有:
{
"id": "TestWaffleWidget.Configuration",
"type": "ms.vss-dashboards-web.widget-configuration",
"targets": [ "ms.vss-dashboards-web.widget-configuration" ],
"properties": {
"name": "HelloWorldWidget Configuration",
"description": "Configures HelloWorldWidget",
"uri": "configuration.html"
}
}
这不协调(“ HelloWorldWidget.Configuration”和“ TestWaffleWidget.Configuration”不匹配),然后引发“在任何通道上未找到用于消息的处理程序”错误。
看来您可能会遇到同样的问题。您正在注册:
VSS.register(VSS.getContribution().id, function(){
但是,除非VSS.getContribution().id
与清单中的“ sample-extension-page”相匹配,否则它将引发no handler错误。
答案 1 :(得分:0)
您需要在VSS.notifyLoadSucceeded()
函数之后调用VSS.register()
函数(在VSS.require()
函数内)。
答案 2 :(得分:0)
您是否将explicitNotifyLoaded设置为true? 使用此设置,错误对我不显示:
ng-repeat
答案 3 :(得分:0)
我在这里也是个大菜鸟,我也花了很多时间。我仔细地遵循了https://github.com/microsoft/vsts-extension-samples/tree/master/work-item-form中的示例,在我的情况下,问题是涉及完整ID。
在示例workItemToolbarButton.html文件中,您具有:
dag_backfill
删除此部分后,它立即起作用(我不知道为什么...):
VSS.register(“ Fabrikam.samples-work-item-form。 sample-work-item-menu”,函数(上下文){
注意:在尝试执行ID拼写检查之前,我已经仔细检查了很多遍,但仍然无济于事。