I've run into an issue in Jira Automation that looks suspiciously like a bug. I wanted to take the results of a JQL search and total up the number of days between two date values in the results. I first used the Branch Rule widget to search up each issue individually and arrived at a function that properly calculated the number I was looking for. However, the Branching Rule widget cannot pass values back to the main rule, so I was unable to do much of anything useful with this result.
To remedy this, I used the Lookup Issues widget to get the same search results and then used a modified version of the same function (I had to slightly change the smartvalues to remove the "issue." prefix, but otherwise it's the same function, see below). When I did, it seemed incapable of properly calculating the same values. Here's the bug report:
Steps to Reproduce
- Create an automation rule you can trigger manually
- Add a Lookup Issues action that performs a search for issues that have to date fields used to define a range of time (we'll call them startDate and endDate).
- Add a Log action that calculates the difference between the two dates for each issue in the search result:
{{#lookupIssues}} {{startDate.format("M/d")}}-{{endDate.format("M/d")}} {{startDate.jiraDateTime.toDate.diff(endDate.jiraDateTime.toDate.plusDays(1))}} {{/}} - Run the rule
- Look at the Audit Log
Expected Results
The calculated numbers should equal the number of days between (and including) the startDate and endDate for each issue.
Ex: 10/11-10/11 1 day, 10/17-10/23 7 days, 10/7-10/7 1 day, 10/18-10/18 1 day, 10/8-10/8 1 day
Actual Results
After the first result, there is no rhyme or reason to the results except that they alternate between positive and negative values.
Ex: 10/11-10/11 1 day 10/17-10/23 -5 days 10/7-10/7 5 days 10/18-10/18 -6 days 10/8-10/8 4 days