user2721590
user2721590

Reputation: 21

Youtrack: Workflow - Shedule rule

I wrote a rule to send an Email with a list of issues which were set to closed in the last week. The Problem is, I always get a lot of emails with the same kontent. (I get one email for each Issue)

Here ist the code i wrote in youtrack-workflow editor:

schedule rule:
weekly on Monday at 12:08:00 [project == {projekt1}] 
{
   var ClosedIssuesList = "";
   for each Issue in project.issues 
   {
        var Date = Issue.updated;
        if (Issue.State == {Closed} && now < Date + 7 days) 
        {
           ClosedIssuesList = ClosedIssuesList + Issue.getId() + "\n";
        }
   }
   project.getUser("username").notify("Closed Issues", ClosedIssuesList);
}

How can I fix this problem? Thanks for Your help!

Upvotes: 1

Views: 1760

Answers (1)

Dave Cherkassky
Dave Cherkassky

Reputation: 413

The workflow runs once for each issue that satisfies the criteria. In your case, the criteria is [project == {projekt1}], which satisfies every issue in the project.

You need to write something like the example that @artem-goutsoul referred to in the comment above. From that example:

weekly on Monday at 12:00:00 [issue == {issue: A-1}] { ...

Replace A-1 with some random issue ID in the project. This issue won't actually be used in the rule, but it will restrict the criteria to a single item. (I supposed that's a bit of a hack, but such is life!)

Upvotes: 0

Related Questions