How can I have the results of a saved search emailed weekly?

How can I have the results of a saved search emailed weekly?  In Jira this was referenced as a subscription. I cannot find this configuration in YouTrack.

Subscribing to searches / filters to be sent weekly is useful to have an email reminder of issues needing attention. By having it sent to a group we are able to get the attention of those who might rarely use YouTrack.  I found subscriptions useful to have the email reminder each morning if there were issues assigned to me or that needed to be corrected based on a complex filter/search. 

0
1 comment

Hi!

You can use an on-schedule workflow to do that. Here is an example of such workflow:

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

exports.rule = entities.Issue.onSchedule({
title: 'YouTrack Digest',
search: '#HELPDESK-1',
cron: '0 0 10 * * ?',

action: function(ctx) {
var issue = ctx.issue;
  var searchRequest = '#Unresolved';  
  function issueString(issue) {
  return '<a href="' + issue.url + '">' + issue.id + '</a>' +
  ' ' + issue.summary;
    }
  var issues = search.search(ctx.ISSUE, searchRequest);
  var text = 'Please consider these issues: <br/><br/>';
  issues.forEach(function(issue) {
      text += issueString(issue) + '<br/>';
    });
  var message = {
fromName: 'YouTrack',
toEmails: ['example@example.com'],
subject: 'YouTrack Digest',
body: [ text
].join('\n')
};

notifications.sendEmail(message, issue);
}});

search: '#HELPDESK-1', - this is an anchor issue. You need to specify an ID of any existing issue so the workflow is executed only once.
var searchRequest = '#Unresolved'; - this is the actual search that you want to use.
toEmails: ['example@example.com'], - an email that you want to send digests to.

And, of course, change the cron part as per the needed schedule.

0

Please sign in to leave a comment.