Change DueDate according to Priority [RESOLVED]

Answered

I need to change the DueDate of my issue according to what priority is selected for that issue.

4 comments
Comment actions Permalink

/**
* This is a template for an on-change rule. This rule defines what
* happens when a change is applied to an issue.
*
* For details, read the Quick Start Guide:
* https://www.jetbrains.com/help/youtrack/standalone/2018.4/Quick-Start-Guide-Workflows-JS.html
*/

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

exports.rule = entities.Issue.onChange({
// TODO: give the rule a human-readable title
title: 'Duedatebypriority',
guard: function(ctx) {
// TODO specify the conditions for executing the rule
var issue = ctx.issue;
return ctx.issue.fields.becomes(ctx.Priority, ctx.Priority.Normal) || ctx.issue.created;
},
action: function(ctx) {
// TODO: specify what to do when a change is applied to an issue
var issue = ctx.issue;
var dueDay = new Date();
var DAY_IN_MS = 24 * 60 * 60 * 1000;

dueDay = Date.now() + 7 * DAY_IN_MS; // + 7 day in MS
issue.fields.DueDate = dueDay;
},
requirements: {
// TODO: add requirements
DueDate: {
type: entities.Field.dateType,
name: 'Due Date'
},
Priority: {
type: entities.EnumField.fieldType,
name: 'Priority',
Immediate: {},
High: {},
Normal: {},
Low: {}
}
}
});

 

 

0
Comment actions Permalink

Hello,

Am I right you managed to resolve this? Do you still need any help?

0
Comment actions Permalink

It has been resolved. I do not need any further help.

0
Comment actions Permalink

Great to hear that, thank you for the update.

0

Please sign in to leave a comment.