Workflow loop through all issues and refer to original job afterward

Answered

When an issue is created I want to search through all issues in the project and check if one of the fields JobNum matches that of any other issue. If it does match, I want to delete the new issue (issue is a draft at this point), or at least mark it to be deleted later by a scheduled rule.

I'm having issues referring back to my original issue that was submitted when I loop through all issues. Any advice? Here's the code I have right now. When I submit a job with the same JobNum, it changes the Review Status of the older job, not the new one as I have intended. The tag "delete later" is added to both issues for some reason.

when issue.isReported() && issue.JobNum != null {
  var num = issue.JobNum;
  var newdate = issue.Booked Date;
  var issuenum = issue.getId();
  var rereview = false;
  for each item in project.issues {
    if (item.JobNum == num && item.getId() != issuenum) {
      item.Booked Date = newdate;
      item.Review Status = {Submitted};
      item.addComment("Job was resubmitted on " + newdate);
      rereview = true;
    }
  }
  if (rereview) {
    issue.addTag("delete later");
    issue.Review Status = {Rereview, see previous job};
  }
   
}

2 comments
Comment actions Permalink
Official comment

Hello Brian, sorry for the delay.

Please replace `when issue.isReported()` with `when issue.becomesReported()`, let me know if it helps. Thank you!

Comment actions Permalink

Indeed, that fixed it sorry for not updating the issue earlier. Thank you so much for the response.

0

Please sign in to leave a comment.