Fionnuala Gibney
Fionnuala Gibney

Reputation: 21

YouTrack email notification using custom fields

I've added a custom field for 'interested parties' (users) in a particular issue, not project specific, and it works fine.

I would like YouTrack to generate emails to their email address on update or change of the issue, like they do to the person who it is assigned to, is this possible?

Upvotes: 2

Views: 2091

Answers (2)

Alexandre
Alexandre

Reputation: 1683

Let's say you want to send notifications by e-mail when a ticket is ready to be reviewed. People responsible for the review are set via a Reviewer custom field (which can contain multiple values). Then you can send notifications as follows:

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

exports.rule = entities.Issue.stateMachine({
  title: 'Workflow',
  fieldName: 'State',
  states: {
    'To Be Reviewed': {
      onEnter: function(ctx) {
        var issue = ctx.issue;
        issue.fields.Reviewer.forEach(function(user) {
          user.notify("Reminder", "This is a reminder", true);
        });
      },
      transitions: {}
    },
  },
  requirements: {
    Reviewer: {
      type: entities.User.fieldType,
      multi: true
    }
  }
});

Upvotes: 1

Alex.V
Alex.V

Reputation: 2116

You can create a custom workflow like the following one:

when  { 
  if (Interested Parties.isNotEmpty) { 
    for each user in Interested Parties { 
      user.notify("subj", "body"); 
    } 
  } 
}

Another point is that you probably do not need this field since you can 'star' an issue on behalf of a user and the user thus will be notified about any changes. Just type star user_name in the command window.

Upvotes: 0

Related Questions