YouTrack Workflow 重置字段值
YouTrack Workflow reset field value
我有一个 YouTrack 的 JavaScript 工作流程,当问题设置为打开时,应该将几个字段重置为 "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 行在代码片段中用注释标记
我应该如何设置这些字段的值?
issue
是上下文对象 (ctx
) 的一部分,而不是参数。所以代码应该是这样的:
onEnter: function (ctx) {
var issue = ctx.issue;
issue.fields['Alpha Approved By'] = null;
...
}
我有一个 YouTrack 的 JavaScript 工作流程,当问题设置为打开时,应该将几个字段重置为 "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 行在代码片段中用注释标记
我应该如何设置这些字段的值?
issue
是上下文对象 (ctx
) 的一部分,而不是参数。所以代码应该是这样的:
onEnter: function (ctx) {
var issue = ctx.issue;
issue.fields['Alpha Approved By'] = null;
...
}