Setting dates after x days of creation date.


I'm trying to set a deadline to a custom field “Deadline" (date field), 90 days after the ticket is created - and if the field “Priority” of the ticket is low. I'll repeat this with other Priorities and number of dates, e.g. 30 days for High Priority tickets. 

Goal is to have this field set upon ticket creation, but also when the priority changes. 

I'm using the workflow below. Youtrack is throwing an error: Processing Issue 78-986588: Cannot set value to custom field Deadline

What am I doing wrong? 


const entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.onChange({
 title: 'Set Deadline for Low Priority Issues',
 guard: function(ctx) {
   return (ctx.issue.fields.isChanged(ctx.Priority) && === 'Low') || (ctx.issue.fields.Deadline === null && === 'Low');
 action: function(ctx) {
   var issue = ctx.issue;
   var creationDate = issue.created;
   var Date = new Date(creationDate.getFullYear, creationDate.getMonth, creationDate.getDate + 90);
   issue.fields.Deadline = Date;
 requirements: {
   Priority: {
     name: 'Priority',
     type: entities.EnumField.fieldType
   Deadline: {
     name: 'Deadline',
     type: entities.Field.dateType
1 comment


You don't need to convert the issue's creation date. Please use the following code instead:

  var creationDate = issue.created;
  var NewDate = creationDate + 86400000*90;

86400000*90 is one day in milliseconds multiplied by days number.


Please sign in to leave a comment.