Automatically Set Due Date

Hi All

We want to be able to set the Due Date of tickets in a project to be 14 working days after creation if the field is left blank on creation.

I've been researching this and no one seems to have a definite answer saying , "this is how you do it".

We have script runner installed and the behaviours plugin if it helps.

I would appreciate hearing from someone on this soon.

Kind regards


4 answers

1 accepted

1 vote

Well, with ScriptRunner, there is a really simple definite answer - write a post-function script that sets the due date to (now + 14)

You have to fiddle with milliseconds and timestamps, but...

issue.setDueDate (new Timestamp (cal.getTimeInMillis() + 14 * 1000 * 24 * 60 * 60))

should do it

Hi Nick

Thanks for getting back so quickly it is greatly appreciated.

There are some bits of script runner I'm still getting to grips with.

I dont know how to write a post function script or where post function scripts go?

Sorry. sad


Scriptrunner adds "scripted function" as a workflow post-function option. Just add a post function to the workflow and you'll see it on the list. Then skim (although you might find the examples lower down more useful)

Hey Adam, As Nic said, above link should be a good start to you. You can play with some basic scripts on Dev environment and get used to it. Cheers Chander

Hi Nic Thanks again. I found the post function where i can add a custom scripted function in the workflow of the project i need. I added the script you provided above as a post function of Open transition in the workflow and published it. When i attempt to create a new ticket in the project with this post function script in place nothing happens to the due date field whether the ticket has a blank due date field or not. Do you have any ideas on why this may be the case? Kind regards Adam

I've missed imports etc, I just wanted to show the basics of messing with timestamps. Have a look at the application log file ( <jira-home>/logs/atlassian-jira.log ) and see what that says. It'll be java stack traces, so you can ignore most of it, but there should be a clear error

Hi Nic Sorry to keep bothering you with this but I am still struggling with this as I am not a coder at all so I dont know what classes I am looking for or need to add where, when or why. Our logs are a mess on our dev system and not sure if they are working correctly or not. Is there any chance you could provide me with the full script that will be required to get this functionality working? Thanks Adam

I use a function like this in plugin code, but should be adaptable to groovy script.

public final static Date rollDate(int datatype, int roll, Date date) {
Calendar cal = GregorianCalendar.getInstance();
cal.add(datatype, roll);
return cal.getTime();

where int datatype is a Calendar type e.g. Calendar.DAY_OF_YEAR and roll is the number of days.

to add , I quite often put these functions into scipted fields and then use simple field assignments in the workflow.

0 vote

Add custom script workflow function:

issue.setDueDate(new Timestamp((new Date() + 14).time))

Make it the first function. I took this from


I am using JIRA Cloud and trying to set the deadline outomatically based on other factors. How can I access Timestamp object on the cloud? I had to add several days to a date (custom field), but don't know how to do it without the TimeStamp or Calendar objects. Or is this a way to access them by using Rest API?

Any helps are appreciated! :)

Suggest an answer

Log in or Join to answer
Community showcase
Emilee Spencer
Published yesterday in Marketplace Apps

Marketplace Spotlight: DeepAffects

Hello Atlassian Community! My name is Emilee, and I’m a Product Marketing Manager for the Marketplace team. Starting with this post, I'm kicking off a monthly series of Spotlights to highlight Ma...

44 views 0 3
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot