-
Bug
-
Resolution: Unresolved
-
Low
-
Minor
-
Jira Software, Jira Service Management, Jira Work Management
Issue Summary
When you use a lookupIssues block along with any mathematical function like plus, diff, multiply, or divide, and there are multiple issues involved, the function applies the value from the first issue to all the subsequent issues instead of using the value from each individual issue.
Steps to Reproduce
Create an automation rule as follows;
- Trigger: Scheduled
- Then: Lookup Issues
- Perform a JQL lookup where atleast two issues are returned
- Then: Add value to the audit log
{{#lookupIssues}} field_1: {{first_value|0}} field_2: {{second_value|0}} math_operator_division: {{#=}}{{first_value.asNumber|0}} / {{second_value.asNumber|0}}{{/}} smart_value_divide: {{first_value.divide(second_value)}} {{/}}
Expected Results
Consider the scenario where there are two tickets returned by the JQL lookup action;
- TICKET-1
- first_value = 5
- second_value = 10
- Ticket -2
- first_value= 12
- second_value = 6
The automation rule should log the following values to the audit log;
field_1: 5 field_2: 10 math_operator_division: 0.5 smart_value_divide: 0.5 field_1: 12 field_2: 6 math_operator_division: 2 smart_value_divide: 2
Actual Results
The value for the second value in the lookupIssues loop onwards is incorrect
field_1: 5 field_2: 10 math_operator_division: 0.5 smart_value_divide: 0.5 field_1: 12 field_2: 6 math_operator_division: 2 smart_value_divide: 1.2 (INCORRECT - this is actually 12 / 10)
The math operation from the second issue in the list onwards uses the first non-zero value it can find in the list (which in the above example is 10)
Suggestion
Instead of using diff/plus/minus/divide, use the mathematical symbols as follows;
diff: {{#=}}{{first_value}} - {{second_value}}{{/}} plus: {{#=}}{{first_value}} + {{second_value}}{{/}} divide: {{#=}}{{first_value}} / {{second_value}}{{/}} multiply: {{#=}}{{first_value}} * {{second_value}}{{/}}