I am creating a very waterfall-ish workflow. I know what happens at every step of the way and how long (roughly) it's going to take.
I need to create 3 issues at a certain point of the workflow (clone issue and link) and set different (hardcoded) original estimates for each of them.
What I'm thinking is something along the lines of:
issue.OriginalEstimate = 10d
I feel this shouldn't be incredibly difficult but for some reason I can't manage it and I can't find any similar topic in the tome of google.
You're close, but there's a couple of things to understand about the estimate field.
First, it's a length of time, and held internally in either seconds or milliseconds (I can never remember which). So you need to feed it a simple, large number
Second, the 10d thing is done in code for the front end and it's about making a duration pretty for the users. They can write, and see, 10d for "10 days", but it's all (milli)seconds in the actual code and data.
Last, the java API can be very helpful - bookmark https://docs.atlassian.com/jira/latest/ - it's not what I'd call "good" documentation in that 99.9% of it is not explained in human terms, but it does what javadoc is supposed to - lists the calls and their input/output.
So, to answer it without you following any links, try:
issue.setEstimate ( 10 * 24 * 60 * 60 )
That assumes seconds, and a 24 hour working day though, so you might need to tweak it.
If you check the documentation you should see your mistake, but I'll help you out here. The built-in IDE-like syntax magic is exactly right, there is NO method of
com.atlassian.jira.issue.MutableIssue#setEstimate(int). It does not exist. There IS a method of
This is probably due to storage-size; A JAVA Long is 64-bits long whereas a JAVA Int is only 32-bits long – Useful for storing time in milliseconds.
TL;DR Cast your value as a Long, not an Int (
issue.setEstimate(Long 288000) )
My willingness to read the documentation is not the issue - it's just that I don't have a technical background so in case it's not written in a somewhat plain fashion, I will not understand it. So don't feel bad for helping me out, it's much appreciated
I've tried your solution and it's giving me another error. Also I'm assuming it should be " long" , not "Long". I tried both and they're the same error anyway.
The difference between variable types still catches me when I'm scripting. Although I completely understand why there are types, coming from a school of coding where every operation mattered, you explicitly tell the code to use the most efficient (working with integers is faster than longs, which are faster than doubles, so you always use the smallest that can contain your answer). As a human, they're all "numbers", we don't think in types of number, so it's not intuitive.
Try coding explicitly, the long way, and shorten it later. For example, for 10 days:
long my_result = 10 * 24 * 60 * 60 * 1000
issue.setEstimate ( my_result )
Although I suspect you can just do a "cast" too -
issue.setEstimate ( (long) 288000 )
Many thanks Nic and Steven for helping me out with this!
Both of the options described by Nic are working. I'll mark this as solved - cheers!
EDIT: Also, just to be clear, there's also no need to import anything. Just the one line is enough:
issue.setEstimate ( (long) 288000 )
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs