Setup info for new issue notifications is incorrect

Answered

In one of the setup steps to enable sending new issue notification to users who create issues through emails, it says the following:

If you choose to send a notification, just add the following lines of code to the Collect related emails on issue creation rule of the Notify Multiple Unregistered Users workflow (right before the Last message related emails=null line):

var reporterEmail = Last message related emails.split(" ",preserveAllTokens).first sendMail(reporterEmail, "Your subject", "Your email body")

The problem is - the line "Last message related emails=null" does not exist anywhere in that code!

Can someone please help?

0
4 comments
Avatar
Permanently deleted user
Official comment

Hi,

The documentation is gonna be updated soon. This code is written in old API. In the new (JS-based) API you need to add the following:

// on top, after 2 other requires
var notifications = require('@jetbrains/youtrack-scripting-api/notifications');

// after issue.fields.lastEmails = null;
var message = {
fromName: 'YouTrack', // set whichever name you prefer
toEmails: lastMessageRelatedEmails.slice(0, 1),
subject: '[YouTrack] New Issue', // set a subject you like
body: 'The text of the notification' // set a full body of your notification
};
notifications.sendEmail(message, issue);

Thanks Mariya - that works!

However, the email does not include the ID of the issue created. How do I include that in my initial issue creation email?

0

And in fact, if there is a way to include the email text that the user entered for the issue, that would be amazing.

Thanks,

Sunil

0

Hello,

I am very sorry for the delay. 

You can modify the workflow considering the following:
1. issue.id will return the ID of the created issue (https://www.jetbrains.com/help/youtrack/standalone/v1-Issue.html#properties);
2. issue.summary and issue.description will return the summary and dewcription respectively (https://www.jetbrains.com/help/youtrack/standalone/v1-Issue.html#properties). 

0

Please sign in to leave a comment.