我有一个YouTrack的JavaScript工作流,当问题设置为Open时,应该将几个字段重置为" null"。这是我用来完成此任务的代码:
Open: {
onEnter: function (ctx, issue) {
issue.fields['Alpha Approved By'] = null; // <- This is where the error points
issue.fields['UAT Approved By'] = null;
issue.fields['QA Approved By'] = null;
issue.fields['PM Approved By'] = null;
},
transitions: {
Working: {
targetState: 'In Progress'
},
Rejected: {
targetState: 'Rejected'
}
}
},
但是,每当我尝试创建问题时,都会收到以下错误消息:
TypeError: Cannot read property "fields" from undefined (workflow-enforcement/workflow-enforcement#20)
第20行在代码段中标有<注释
我应该如何设置这些字段的值?
答案 0 :(得分:1)
issue
是上下文对象(ctx
)的一部分,而不是参数。因此代码应如下所示:
onEnter: function (ctx) {
var issue = ctx.issue;
issue.fields['Alpha Approved By'] = null;
...
}