YouTrack InCloud 7.0 Help

Notify Multiple Unregistered Users

This workflow is used as part of the Mailbox Integration that enables using YouTrack as a help desk. For a detailed description of this integration, see Use YouTrack as a Help Desk

You can use this workflow to send email messages to any email address, including unregistered users. If overused, sending email messages to unregistered users can slow down the performance of your YouTrack server, which is not designed for use as a bulk email service. You can configure a system property to set a daily email message limit. For more information, see Configuration Parameters.

This workflow manages a of email addresses that are stored in the Last message related emails and All related emails fields. It also includes a rule that sends email messages to unregistered users when a comment is added to an issue that was reported by sending an email to a specific mailbox.

File Namejetbrains-youtrack-notifyMultipleUnregisteredUsers
Auto-attachedno
RulesCollect related emails on issue creation (stateless)
Send notifications to all unregistered users (stateless)

To enable this workflow:

  1. Add a string-type field with the name Last message related emails to your project.
  2. Add a string-type field with the name All related emails to your project.
  3. Attach the Notify Multiple Unregistered Users workflow to your project.

For this workflow to function properly, there are a few additional settings you need to configure in your YouTrack instance:

  • Configure your project to send notifications with the email address of your feedback or support account.
  • Configure and enable the Mailbox Integration feature.

For a complete description of this setup, see Use YouTrack as a Help Desk.

Use Case

This workflow supports using YouTrack as a help desk. When an issue is reported by email, the email addresses in the From and CC fields are added to the issue. These email addresses then receive email notifications when the issue is updated.

Rules

This workflow includes two rules. The first rule manages the list of email addresses and the second sends notifications to these email addresses when an issue is updated.

Collect related emails on issue creation

This rule collects the email addresses stored in the Last message related emails field and copies them to the All related emails field.

rule Collect related emails on issue creation when issue.becomesReported() { if (Last message related emails.isNotEmpty) { for each email in Last message related emails.split(" ", preserveAllTokens) { if (email.isNotBlank && !(email.eq(getNotificationEmail(), ignoreCase))) { if (All related emails.isEmpty) { All related emails = email; } else if (!(All related emails.split(" ", preserveAllTokens).contains(email))) { All related emails = All related emails + " " + email; } } } Last message related emails = null; } }

Send notifications to all unregistered users

The next rule sends notification to unregistered users whose email address is stored in the All related emails field. This is used to send notification to the email address of a person who reported an issue by sending an email to a specific inbox. Additional email addresses that were set in the To and CC fields are also notified.

The email message is formatted as a reply to the original email.

rule Send notifications to all unregistered users when comments.added.isNotEmpty { if (All related emails.isNotEmpty){ var myComment = comments.added.first; if (myComment.permittedGroup == null) { var body = " "; // getting subject var subject = summary; if (!(subject.startsWith("Re:", opts))) { subject = l10n ( Re: {summary} ); } // adding attaches var text = myComment.text; for each attach in attachments.added { text = text + "\n[file:" + attach.name + "]"; } // getting list of emails var allRelatedEmails; var addToCC = " "; var replyTo = " "; var lastCommentAuthorPersonal = " "; allRelatedEmails = All related emails.split(" ",preserveAllTokens); // case 1: the message from unregistered user, got from email if (Last message related emails.isNotBlank) { var lastMessageRelatedEmails = Last message related emails.split(" ", preserveAllTokens); // select only emails of those, who haven't received a copy of the message yet for each email in allRelatedEmails { if (email.isNotBlank && !(lastMessageRelatedEmails.contains(email) || email.eq(getNotificationEmail(), ignoreCase))) { if (replyTo.isEmpty) { replyTo = email; } else { addToCC = addToCC + " " + email; } } } // all the new users should be added to list of all related emails for future comments for each email in lastMessageRelatedEmails { if (email.isNotBlank && !(allRelatedEmails.contains(email) || email.eq(getNotificationEmail(), ignoreCase))) { All related emails = All related emails + " " + email; } } lastCommentAuthorPersonal = lastMessageRelatedEmails.first; Last message related emails = null; body = wikify(text); } else { // case 2: comment from agent replyTo = All related emails.substringRelative(" ", pos: before); addToCC = All related emails.remove(replyTo, side:start).trim(side: both); lastCommentAuthorPersonal = myComment.author.fullName; // getting quoted text var quotedText = " "; var lastVisibleComment = myComment; lastVisibleComment = null; for each comment in comments.oldValue { if (comment.permittedGroup == null) { lastVisibleComment = comment; } } if (lastVisibleComment == null) { quotedText = wikify(issue.description); } else { quotedText = wikify(lastVisibleComment.text); } body = l10n( <div style="font-family: sans-serif"> <div style="padding: 10px 10px; font-size: 13px; border-bottom: 1px solid #D4D5D6;"> {wikify(text)} </div><blockquote type="cite"><div style="font-size: 13px; color: #888;">In reply to:<br><br> {quotedText} </div></blockquote><div style="margin-left: 44px; padding: 4px 0 8px; color: #888; font-size: 11px; margin: 20px 0; padding: 8px 0; border-top: 1px solid #D4D5D6;">You have received this message because you are a participant of the conversation in the issue {getId()} . Sincerely yours, YouTrack</div></div> ); } if (addToCC.isNotEmpty) { addToCC = addToCC.replace(" ", ","); } // sending message when there is someone to send it to if (replyTo.isNotEmpty) { sendMail(lastCommentAuthorPersonal, getNotificationEmail(), replyTo, addToCC, subject, body); } } } }
Last modified: 29 September 2016