I'm having trouble getting size to count to zero when there is nothing in a list.
Through some other funky use of smart values, I have built a variable (one per squad using the same syntax) that holds the sprints for each ticket delivered by a squad for a specific Epic. The string held in teamSprintsTESTamps looks like this:
Amps Sprint 7@Amps Sprint 7@Amps Sprint 5@Amps Sprint 6@Amps Sprint 7@Amps Sprint 6@Amps Sprint 6@Amps Sprint 5@Amps Sprint 7@Amps Sprint 6@Amps Sprint 7@Amps Sprint 5@Amps Sprint 4@Amps Sprint 7@
Using the following, the result given is "Amps: 4" (correct)
Amps: {{teamSprintsTESTamps.substringBeforeLast("@").split("@").distinct.size|0}}
For another team that only had one task in the Epic that they delivered in one sprint, the string held in teamSprintsTESTheat looks like this:
Heat Sprint 7@
And the result returned is "Heat: 1", which is also correct:
However for the teams that did not contribute to the specific epic, the result returned by .size is 1 (incorrect).
For the team that were not part of the delivery of Epic X, the following code:
Bigbus: {{teamSprintsTESTbigbus.substringBeforeLast("@").split("@").distinct.size|0}}
A. #{{teamSprintsTESTbigbus}}#
B. {{teamSprintsTESTbigbus.substringBeforeLast("@")}}
C. {{teamSprintsTESTbigbus.substringBeforeLast("@").split("@")}}
D. {{teamSprintsTESTbigbus.substringBeforeLast("@").split("@").distinct}}
E. {{teamSprintsTESTbigbus.substringBeforeLast("@").split("@").distinct.size}}
Returns the following output (to prove to you there's no value in that variable:
Bigbus: 1
A. ##
B.
C.
D.
E. 1
Is there a way to get the correct result of 4 for Amps and get the correct result of 0 for Bigbus?
*Squad names have been changed to protect the innocent
What is in the variable teamSprintsTESTbigbus when they did not contribute to the specific epic: an empty string, just a trailing @ symbol, something else?
Knowing that may help to use conditional logic to handle the 0 and non-zero cases.
Kind regards,
Bill
Looks like an empty string:
A. #{{teamSprintsTESTbigbus}}#
Output
A. ##
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks; that looks like it is null.
Are you trying to create one smart value expression that works for all cases, or are you open to a couple of them? (e.g., use conditional logic to handle the 0 case separately from the others)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Bill Sheboy
It's hard to say without seeing the outcome. If you have the time, please hit me with both and I'll test to see which best suits the use case
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FYI for stuff like this, you really do need to experiment. There is a bit of exploring required as not everything for rule behavior is documented to know what will / will not work...particularly when fields could be null. Anyways...
Assuming the variable is empty when there are no sprints, and it ALWAYS ends in an At-sign @ when there are sprints, a conditional block may be used, checking the length of the variable.
{{if(teamSprintsTESTbigbus.length().gt(0), teamSprintsTESTbigbus.substringBeforeLast("@").split("@").size, 0)}}
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good call, The variable will always contain an @ delimiter IF there is any data. Checking length or the existence of the @ delimiter should work.
That worked. Thanks @Bill Sheboy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.