Forums

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

Automation smart values list does not sum at all

Piotr Intres
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 11, 2024

Hi there,

I am struggling with following issue:

I have two projects - let's call them SCRUM and DEPLOYMENT.

Issues (stories/bugs/tasks/) I am cloning and moving from SCRUM project to DEPLOYMENT project.
Let's think of SCRUM story - called SCR-1 (+5 subtasks) and cloned story DEP-1. Both stories are related  by "clones" relation. From the level of DEP-1 I need to collect all the time spent on SCR-1 (together with the subtasks) and put them as sum into a custom field.

Now as used in automation (printing as issue comment for debug purpose):

1.

{{issue.issuelinks.outwardIssue.sub-tasks.timetracking.timespentseconds}}

returned value:  
[11040, 5820, 0, 900, 31440] 

2. 

{{issue.issuelinks.outwardIssue.sub-tasks.timetracking.timespentseconds.sum}}

returned value:  
<no value> 

3. 

{issue.issuelinks.outwardIssue.sub-tasks.timetracking.timespent}}

resulted value:
[3h 4m, 1h 37m, 0m, 15m, 1d 44m] 

Please mind the difference at the last position!! It should be 8h 44m (and that what Tempo is showing on that issue).

4. 

{{issue.issuelinks.outwardIssue.sub-tasks.timetracking.timespent.sum}}

returned value:  
<no value>

 

Questions:

1. Why there is a difference on the last position of that array when the value of TimetrackingBeam is correct:

TimetrackingBean{originalEstimate='1h', remainingEstimate='0h', timeSpent='8.73h', originalEstimateSeconds=3600, remainingEstimateSeconds=0, timeSpentSeconds=31440}

2. Why I can't sum up any of them as a list? It at least should be possible with the Seconds.

3. Is there any other way to achieve what I need?

1 answer

1 accepted

3 votes
Answer accepted
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.
September 11, 2024

Hi @Piotr Intres  -- Welcome to the Atlassian Community!

Without seeing the details of your automation rule and the audit log for the rule execution...

 

Those two time tracking smart values have different purposes:

  • {{issue.timetracking.timeSpent}} is the "pretty print" one, making it human-readable.  And thus it is text type.
  • {{issue.timetracking.timeSpentSeconds}} is the seconds only, making it helpful for math.  It is a number with no units identifier (of seconds).

I recommend using timeSpentSeconds for your scenario.

 

Next, you are referencing nested lists of things: subtasks within linked issues and linked issues within the original issue.  When that happens, you observe the array format with the square brackets inside of the outer list items.  Also leading to some empty [] cases.

And...the {{issue.issuelinks}} smart value is impacted by the direction of links, leading some entries having inner, outer, or both types in the list.

Finally, the {{issue.subtasks}} smart value is dynamic, loading the data just in time.  If it did not you could imagine a cross-linked issue scenario that would attempt to load many issues (through links and subtasks) when the rule starts!

 

There are two possible fixes for those things: use dynamic JQL to load all the subtasks with Lookup Issues to sum or use list iteration and math operations to join the values together for summation...where the key is iterating over the correct thing and adding 0 defaults as needed.

{{#=}}0 {{#issue.issuelinks.outwardIssue}}+0{{subtasks.timetracking.timeSpentSeconds.join(" +")}}{{/}} {{/}}

The expression above iterates over any outwardIssue links found, and then joins together any time tracking values for any subtasks found.  The whole thing is wrapped in a math expression, with a zero default at the front, to give a total number of seconds.

 

Kind regards,
Bill

Piotr Intres
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 12, 2024

Hi @Bill Sheboy 

Thank you very much for your answer - it worked as a charm.

Kind regards,

Piotr

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events