Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Warren Turner June 23, 2022

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

0 votes
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.
June 23, 2022

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

Warren Turner June 24, 2022

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

Warren Turner June 24, 2022

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

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.
June 24, 2022

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.

Warren Turner June 27, 2022

@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
AUG Leaders

Atlassian Community Events