1

我正在编写一个动作来为用户故事创建默认任务。这是我走了多远:

var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
var entities = require('@jetbrains/youtrack-scripting-api/entities');

exports.rule = entities.Issue.action({
  title: 'Create default subtasks',
  command: 'tt-create-subtasks',
  guard: function(ctx) {
    // Condition that must be met to enable the custom command:
    return ctx.issue.fields.Type.name == "User Story";
  },
  action: function(ctx) {
    var issue = ctx.issue;
    var newIssue = ctx.issue.copy(issue.project);
    newIssue.summary = 'API spoofing';
    newIssue.fields.Type = ctx.Type.Task;
//    var link = newIssue.links.add(issue);  ????
    workflow.message('Default task created under issue ' && issue.description);
  },
  requirements: {
    Type: {
      type: entities.EnumField.fieldType,
      Task: {}
    },
  }
});

如何创建一个新的链接来创建newIssue一个子任务issue

我已经查看了代码完成提供的内容、问题属性的文档、SO 问题、YouTrack 中已经存在的工作流代码,但我被困住了......

4

1 回答 1

1

您也应该指定问题链接。以下代码应该可以工作(newIssue将是的子任务issue):

newIssue.links['subtask of'].add(issue);

您可以在此处找到示例:https ://blog.jetbrains.com/youtrack/2017/12/make-it-workflow-part-4-generating-new-issues/

于 2021-04-05T15:24:37.910 回答