Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,328
Community Members
 
Community Events
165
Community Groups

I want to add the worklog from JSM to the worklog from JS to get a total time spent

Hi!

I hope someone might be able to answer a puzzling scenario.

I am trying to create a manually run automation rule that provides me a sum total across linked issues so we can see how much time is spent by both the SD Agents and the 3rd line Support team for completing an issue. Our Account team would like to be able to do this with the click of a button in JSM instead of having to export to csv, then manipulate the output to give the total.

This should catch all "causes" issues if there are more than one.

I can get the worklog.timespentseconds from JSM

{{issue.worklog.timeSpentSeconds}}

I can get the worklog of {{issuelinks.outwardIssue.worklog.timespentseconds}}

The automation log shows this:

 

Log action
Log
Time on SD issue: 3600
Log action
Log
Time on Linked issues out: [7200], [10800]
Log action
Error rendering smart-values when executing this rule:
Token is empty: Total time spent across all linked issues: {{#}}{{sdissuetotal}} + {{outwardissuetotal}} / 3600{{/}}

 

When I amend the second smart value to {{issuelinks.outwardIssue.worklog.timespentseconds.sum}} I get no value.

 

Log action
Log
Time on SD issue: 3600
Log action
Log
Time on Linked issues out:
Log action
Error rendering smart-values when executing this rule:
Token is empty: Total time spent across all linked issues: {{#}}{{sdissuetotal}} + {{outwardissuetotal}} / 3600{{/}}

My expectation was this would return an 18000 summed total second value. At that point I could simply add them and divide by 3600 to get minutes spent total.

I referred to this previous question: 

https://community.atlassian.com/t5/Automation-questions/How-to-get-sum-timespent-from-linked-issues/qaq-p/1471579

but for some reason the sum doesn't add the array values as expected to provide a total linked issue value which I can then add to the JSM total.

Does anyone have any ideas on how to solve this? Or is it a bug in the sum function that the A4J team need to address?

Thanks in advance

Warren

 

1 answer

Hi @Warren Turner 

To provide some context, would you please post images of your complete rule, details of the summation/edit components used, and of the audit log details showing the rule execution?  Thanks!

Kind regards,
Bill

Hi @Bill Sheboy 

Thanks for taking the time to look at my query.

This is the rule and the two variables I am checking in the log:

rule and variable details.png

And this is the result of the two different smart value returning the results.

The first image shows it producing the worklogs second values, which seems to be as an array of values, when I don't use the .sum on the outward issue variable.

The second one shows an empty result when I add the .sum to aggregate the values into a total seconds amount

audit log.png

Thanks

Warren

This is the variable tweaked with the .sum added to which produces the second log above. Its weird as I thought the aggregate would simply add value 1 to value 2 to produce the sum total of the worklog, and then I can simply add the two and then divide to get total mins! Logically it seems sound but I am hitting a brick wall.

with .sum option.PNG

I wonder if that time value is text (because of possible units of measure). Perhaps try adding .asNumber.sum to convert before summation.

Also, smart values are case-sensitive, and I note you made that one all lower case.  Perhaps try making it match your first variable and the documentation: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--worklog--

Unfortunately when we enter invalid smart values in a rule, they often just collapse to null rather than showing an error.

@Bill Sheboy 

Thanks for you input. I eventually managed to get it to work :-)

For those who may be interested this is how I did it:

{{issue.timetracking.timeSpentSeconds.plus(issuelinks.outwardIssue.timetracking.timeSpentSeconds.sum)}}


This basically takes the current issues time tracking logs and adds it to the linked issues totals to get a sum of seconds across all items.

I simply then cast that into hours as a new variable thus:

{{#=}}{{currenttotal}} / 3600{{/}}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Atlassian Automation

Jira Automation: Sum Up Story Points Roundup (Initiatives -> Epics -> Story/Tasks -> Subtasks)

Hi Everyone, In this roundup we combine all the jira automation rules to sum up story points across different issue types. We start from the lowest level, summing up story points from sub-tasks t...

1,871 views 2 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you