2017-09-14 41 views
0

我想將一個項目中的問題的值複製到另一個項目中的問題中。 這就是我:在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" 
    } 
    } 
}); 

的問題是在這條線:

​​

應該怎樣做呢?

回答

1

很可能,您的實例中沒有「DueDate」字段(因爲默認字段被稱爲「到期日期」)。如果是這樣,你的代碼行應該看起來像這樣:

normalIssue.fields['Due Date'] = issue.fields.Date; 
相關問題