Hi
I want to calculate the amount of time between certain workflow statuses and for the result to be in hours with 2 decimal places.
For testing I am taking the minutes since creation, dividing by 60 and putting this in a variable called hours:
{{#=}}{{now.diff(issue.created).minutes.abs}} / 60{{/}}
The variable is fine and prints to the log as {{hours}}
But I can't get the formatting to work. I tried {{hours.format("###.##")}} following the answer in this question but that produces no output at all. Any tips welcome, thanks!
Hi @Julia Foden
I was able to do this with ROUND() so you could try:
{{#=}}ROUND({{now.diff(issue.created).minutes.abs}} / 60, 2){{/}}
Best regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Julia,
Maybe try to put the word issue in front:
{{issue.hours.format("###.##")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also tried this solution, but cannot get a custom created variable to format to display 2 decimals
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karen Kelly - did you see Bill's response above? Can you share what you have that is not working?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @John Funk ,
Yes, the rounding works perfectly but if I want to display 2 decimals on e.g. 100 like 100.00 I can get t right using a custom field format e.g.
{{issue.customfield_xxx.format("##.00")}}
But not on my custom variable {{total}}
tried everything {{total.format("##.00")}} doesn't work and {{issue.total.format("##.00")}} neither
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ah, it might be something related to how a variable handles values - meaning it might not be natively using it as a number. But that's beyond me.
Maybe @Bill Sheboy can weigh in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karen Kelly
Are you trying to change the stored value in the Total field or the output in some message, email, etc.?
If you are trying to change the stored value of Total, what you describe will only work if you have a text field. If it is numeric, Jira will most likely truncate any trailing, zero digits.
Or...is this a created variable? Sorry as I was unclear on you scenario.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello @Bill Sheboy ,
I created this custom variable as part of my automation, it is the sum of a few fields, I just want the output to how with 2 decimals instead of truncated. Referencing it in the summary of the issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for clarifying, Karen.
What I think is happening is created variables are always text type (at this time...) and so your variable needs to be converted to a number for the format() function to work. (Format can also work with date/time types...which are really number behind the scenes.)
Please try this:
{{total.asNumber.format("##.00")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! This is the perfect solution! I appreciate the feedback
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm trying to do the same, but my decimals are not showing, and the number is rounded down to the next integer it seams. 45 minutes show as 0 h and 1 hour and 40 minutes show as 1h.
I'm trying to create a table with the time tracking details of the children and their descendants of an epic, as with this new issue type hierarchy, the timetracking doesn't seem to roll-up automatically to the parent (Epic).
I'm using this in automation to do this:
This creates a table in a multi-line text field.
The problem that I'm trying to solve is the formatting of the time tracking fields into a text field. I want 1 hour and 15 minutes to become 1.25 h and 45 minutes to become 0.75 h etc.
how can I get that to work? It seems I'm always losing the decimals when I use the below syntax:
{{lookupIssues.Remaining Estimate.sum.divide(3600).format("##.##")}}
Thank you for your insights!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ward Schwillens_ Schwillie
First thing, as this is an older thread I recommend creating a new question and perhaps adding a link back to this one. Otherwise only the people following this one will see it to offer suggestions.
When you create your new question, please include images of your complete rule, the action details, and the audit log details showing the rule execution. Those will provide context for the community to offer suggestions. Thanks!
Until we see those...
What version of Jira are your using: Cloud, Server, or Data / Center. For Server and Data / Center, I do not believe all of those fields are available to the lookup issues action yet, and so they could be null. Instead of using the lookup issues action, you would need to use either bulk-handling for issues or a REST API issue search with the Send Web Request action.
If you are using Jira Cloud, those are not the correct smart values to manage the time tracking values as numbers: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--issue.timetracking--
Instead please try these:
{{lookupIssues.timetracking.originalEstimateSeconds}}
{{lookupIssues.timetracking.remainingEstimateSeconds}}
{{lookupIssues.timetracking.timeSpentSeconds}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.