Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Smart Value for Total Issues with multiple Sprint Values

Aaron D March 8, 2024

I'm trying to create a Smart Value that totals the number of issues that contain multiple Sprint Values from a JQL query.

Purpose is to calculate number of rollover tickets from the previous month for a report.

I don't have the option of installing or using addons so limited to a solution of base Jira.

Been working on this and best I could think of is the below template..

{{lookupIssues.[issues with multiple sprint values].size}} 

Any suggestions would be appreciated.

1 answer

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 8, 2024

Hi @Aaron D -- Welcome to the Atlassian Community!

In my opinion, this is a bit challenging in rules: the sprint field can behave like a single value, a list, or an array...apparently based on context.

Here is an approach I believe works:

{{#=}}0{{#lookupIssues}}{{#if(sprint.join("~").split("~").size.gt(1))}}+1{{/}}{{/}}{{/}}

How this works (with documentation links added):

One would think the join("~") is not needed, and that we could just count the sprints.  Yet testing shows some "fuzzy" behavior, forcing us to explicitly create a list with which to count entries.

Kind regards,
Bill

Aaron D March 11, 2024

Appreciate the help Bill. Unfortunately no success on my end. Did try other clever ideas like trying to join the string values and using length as a deciding value if to add to the count. But no luck.

I think the limitation might be with the sprint variable being limited to just triggers based off Sprint Values 

Thanks.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 11, 2024

Are you using Jira Cloud, Server, or Data Center version?

Would you please post an image of your complete rule, and audit log details, for some context?

 

The example I provided definitely works in a rule with any trigger for Jira Cloud, as it uses the result of a lookup issues action, not for a sprint from a sprint-related trigger.

And...context is key for smart values:

  • when the trigger is for a sprint-related one, {{sprint}} refers to that trigger sprint...
  • however if once inside a rule, if there is an issue in scope at a particular point in the rule, {{issue.sprint}} and {{sprint}} are the same thing; it is no longer the sprint which triggered the rule

 

Aaron D April 1, 2024

I'm on the Server version and unfortunately unable to share a screenshot.

When running the rule it is returning the value "0" but the true return value should be "2". Audit log is returning success with no error messages for me to see.

Testing the greater than value using .gt(0) still will return a "0" value.

Will the value code change using a Jira Server version?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 1, 2024

Some things are the same and some are different for Jira Cloud versus Server versions of automation rules.  I am using Jira Cloud and so cannot experiment directly with the expressions.

 

Let's try breaking this down into pieces.  To go faster, I recommend creating a separate, scheduled-trigger rule, with only the lookup and a write to the audit log.  That can be called manually for testing.

 

First, let's confirm what is in the sprint field when there are multiple sprints.  Please try writing these to the log:

{{#lookupIssues}}{{key}}:{{sprint}}; {{/}}

What we expect to see is a list of keys and sprints, for example such as this:

ABC-123:sprint 1, sprint 2; ABC-456:sprint 3; ABC-789:sprint 2; sprint 4; ABC-222:; 

 

Then try checking the counts:

{{#lookupIssues}}{{key}}:{{sprint.size}}; {{/}}

What we expect to see for that one is:

ABC-123:2; ABC-456:1; ABC-789:2; ABC-222:; 

The last example as no sprints, and so the size will be null.

 

Suggest an answer

Log in or Sign up to answer