在YouTrack中复制日期字段的值

时间:2017-09-14 17:40:33

标签: javascript youtrack

我想将一个项目中的问题的值复制到另一个项目中的问题中。 这就是我所拥有的:

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

exports.rule = entities.Issue.onChange({
  // TODO: give the rule a human-readable title
  title: 'Date-propagation',
  guard: function(ctx) {
    var links = ctx.issue.links['depends on'];
    return ctx.issue.isChanged("Date") || !links.added.isEmpty() || !links.removed.isEmpty();
  },
  action: function(ctx) {
    var issue = ctx.issue;
    var links = issue.links['depends on'];
    function updateIssue(normalIssue){
      normalIssue.fields.DueDate = issue.fields.Date.value;
    }
    function checkList(list){
      if(list.isNotEmpty())list.forEach(function(normalIssue){updateIssue(normalIssue);}) ;
    }

    //checkList(links.removed);
    checkList(links);
    // TODO: specify what to do when a change is applied to an issue
  },
  requirements: {
    Date: {
      type: entities.Field.dateType,
    },
    Depend: {
      type: entities.IssueLinkPrototype,
      outward: 'is required for',
      inward: "depends on"
    }
  }
});

问题出在这一行:

normalIssue.fields.DueDate = issue.fields.Date;

应该怎么做?

1 个答案:

答案 0 :(得分:1)

最有可能的是,您没有“到期日期”。您的实例上的字段(默认字段称为'截止日期')。如果是这样,您的代码行应如下所示:

normalIssue.fields['Due Date'] = issue.fields.Date;