The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Copy remaining estimate and then convert into hours in Calculated field

James Graham
November 7, 2018

Hi, 

 

I am copying remaining estimate into another field during a workflow transition. However, the data that gets copied is in seconds. I would like to present it as hours in a calculated field. This is what I have so far:-

<!-- @@Formula:
if (issue.get("customfield_13315")==null)
return null;
return (issue.get("customfield_13315"))/3600;-->

This isn't returning any value to the field.

Please help :)

Thanks

James

 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Nic Brough -Adaptavist-
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 Champions.
November 7, 2018

Remaining time on an issue is not a custom field, so I suspect your "get" commands are not getting the right thing.

Unless you have defined a custom field for it, in which case, start with a look at the type of field it is.  Numeric?  Holds number of days, hours or minutes?

James Graham
November 7, 2018

Hi,

I am copying remaining estimate into a number field and then trying to use a custom field to convert back into hours. I can get the time in seconds but when I try to convert it into hours, I get nothing. Its quite frustrating.

Thanks

James

Nic Brough -Adaptavist-
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 Champions.
November 7, 2018

Ok, I think it might be converting with the wrong variable types.  Could you try these two lines as calculations and see what they do (on any issue that has a number in the seconds field)

return (issue.get("customfield_13315"));

return (issue.get("customfield_13315"))/1;

I know a divide by 1 looks a bit odd, but it's a test to see if it gives you an empty result instead of the same number you get from the other line, as it would show a conversion is going wrong!

Like James Graham likes this
James Graham
November 7, 2018

HI Nic,

 

This line: return (issue.get("customfield_13315")); Returns 10,800 (The issue has 3H remaining).

 

This line: return (issue.get("customfield_13315"))/1; Returns nothing and as such the field is not visible on the form view.

 

Thanks

 

James

Nic Brough -Adaptavist-
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 Champions.
November 8, 2018

Ok, that is what I suspected then - the division is resulting in an output that does not work for loading the field.  The /1 returning a failure is consistent with that!

My guess is that there's something like a type conversion going wrong - if for example the output of a division is a float, and Jira only (usually) works with doubles and longs.

I'm not sure how you'd fix that in this scripting language.  If it were plain Java, a simple cast or explicit conversion would work fine, but I'm not sure about your scripting functionality

James Graham
November 9, 2018

Thanks Nic