Scriptrunner additional issue actions: set original estimate

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.

1 answer

1 accepted

1 vote
Answer accepted

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 - 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.

Thanks for that, it's very useful info.

One thing though, what method do I need to import for this? 

As you can see, I tried importing MutableIssue but it doesn't fix the error.image2016-8-12 12:56:4.png


Where is this script running?  If it's a post-function, I'm not sure you need import anything.

Yep, it's a Script Post-Function / Clones an Issue and Links.


The other imports are for a different function, I need to set a custom field as well for the issues that I clone.

Steven Behnke Community Champion Aug 12, 2016

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 com.atlassian.jira.issue.MutableIssue#setEstimate(Long).

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 smile


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.

image2016-8-16 13:22:50.png

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 )

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

397 views 6 0
Join discussion

Atlassian User Groups

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!

Find my local user group

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

Groups near you