Workflow: Shedule rule problem

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 Send for the project an Email with a List of all closed Issues in the last week
weekly on Monday at 12:08:00 [project == {comWORK}] {
  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("waldemar.merk").notify("Closed Issues", ClosedIssuesList);
}

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

Yours sincerely
Waldemar
2 comments
Comment actions Permalink
Hi
You need some logic to make this fire for only one issue.
Something like (where cW-1 is a valid ticket in your comWork project):
weekly on Monday at 12:08:00 [issue == {cW-1}] {
  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("waldemar.merk").notify("Closed Issues", ClosedIssuesList);
}
0
Comment actions Permalink
I'd also suggest using:
project.leader.getissues instead of project.issues.  getissues allows a saved search to be used to narrow down the list of issues.  This means that the selection logic can be controlled through the standard UI of YouTRACK instead of digging into workflows.
0

Please sign in to leave a comment.