var entities = require('@jetbrains/youtrack-scripting-api/entities');
var notifications = require('@jetbrains/youtrack-scripting-api/notifications');
exports.rule = entities.Issue.onChange({
title: 'Send Email Notification',
guard: function(ctx) {
return true;
},
action: function(ctx) {
var issue = ctx.issue;
var recipients = ['[email protected]'];
var emailTemplate = '<html><body>' +
'<p>Issue {{issue.id}} wurde aktualisiert.</p>' +
'<p>Zusammenfassung: {{issue.summary}}</p>' +
'<p>Status: {{issue.State.name}}</p>' +
'</body></html>';
var email = notifications.email({
to: recipients,
subject: 'Aktualisierung von Issue ' + issue.id,
body: emailTemplate
});
notifications.send(email);
}
});
I try to send an email to the creator of the ticket with the content of the comment when a comment has been added to the ticket. However, I always get the error message TypeError: notifications.email is not a function or Message contains an undefined list of recipient email addresses or the list is empty. What did I wrong?
It should be notifications.sendEmail(). Here is an example you can refer to:
Also, here is the corresponding documentation: https://www.jetbrains.com/help/youtrack/devportal/v1-notifications.html#functions