Fill custom field in Workflow

When an issue is created, I would like to add the issue creation date to a custom field (CreatedAt). I cannot get it working. When the issue is created this field always stayes empty. First I tried to find the field

Here is the code I use:


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

exports.rule = entities.Issue.onChange({
  title: 'Created_at_update',
  guard: function(ctx) {
    issueCreated = ctx.issue.created;
    return ctx.issue.becomesReported;
  },
  action: function(ctx) {
    ctx.fields.CreatedAt = issueCreated;
  },
  requirements: {
     CreatedAt: {
      name: 'CreatedAt',
      type: entities.Build.fieldType
    }
  }
});

 

Maybe someone can help me because I have no idea what I'm doing wrong,

1 comment
Comment actions Permalink

Hi,

First of all, issue.created is a date (a number of millis), while CreatedAt is a Build (as you stated in your requirements). Could you please clarify your use-case? Depending on it you may need to change a field type or change the logic somehow.

0

Please sign in to leave a comment.