Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Script Runner- Due date Set Up



I am trying to write a script for script runner behaviors for the request below; 

If the Risk Level custom field is high, due date will be auto selected 7 days from ticket created

If the Risk Level custom field is medium, due date will be auto selected 30 days from ticket created

If the Risk Level custom field is low, due date will be auto selected 90 days from ticket created

I am not familiar with script writingas you can see and here is what I have came up with.

Could you please help me with it since it does not work?



def RiskLevelfield= getFieldByName("Risk Levels")

def DueDate = getFieldByName("Due Date")


def RiskLevel = RiskLevelfield.getValue() as RiskLevel


if ( == "High") {

issue.setDueDate(new Timestamp((issue.dueDate + 7).time)) 


if ( == "Medium") {

issue.setDueDate(new Timestamp((issue.dueDate + 30).time)) 


if ( == "Low") {

issue.setDueDate(new Timestamp((issue.dueDate + 90).time)) 




else {



Thank you so much!

2 answers

Create a behaviour on the "RiskLevel" field with the following server-side script:

def dueDateField = getFieldByName("Due Date")
def riskLevel = getFieldByName("Risk Levels").value

def dateToSet

if (riskLevel == "High") {
dateToSet = new Date() + 7
} else if (riskLevel == "Medium") {
dateToSet = new Date() + 30
} else if (riskLevel == "Low") {
dateToSet = new Date() + 90


@Roland Holban (Adaptavist)

I have tried this on a test project by using Priority field instead of Risk Level and it does not work. Please see the screen shot below. Do you see anything wrong it?

Thank you.


Like Saitej Namburi likes this

Calling getValue() on the priority field actually returns a Priority object. So to use it like you want to you have to access its name property:

def priority = getFieldById("priority")

Also, Im not sure why your field is called "Priority [System]", every time I've seen it was always just called "Priority"...

Like Dave Liao likes this

@Roland Holban (Adaptavist)

Here is what I have tried and still nothing. Any ideas why?

Thank you for your patience and understanding.



@Roland Holban (Adaptavist)

I also tried with a custom field called " SEVERITY" to see of it works. But it did not. Does it work on your system? We use Jira v7.11.2, not sure if that makes any difference.


What type of field is SEVERITY?

It is " Select List (multiple choices)" .image.png

That should definitely work...

Is your behaviour mapped to the correct project/issue types? 

Like Dave Liao likes this

I tried to add conditions , no change. I change the severity on the ticket several times but no values are being assigned to " due date" . Please see below screen shots. 




Like Zhuxin Wang likes this
Dave Liao Community Leader Nov 03, 2020

@Elif Alverson (and to anyone else running into this issue), use getFieldByID("duedate"). Due Date is a Jira system field, so you need to pull it by its ID.

Your sample script above works perfectly for my use case.  Just one question:  How do I add "business days" to the Due Date instead of standard days?  How do I add 7 business days (to exclude Saturday and Sunday)?

For example:

Current date = January 1st Monday. 

Current date + 7 days = Monday January 8th

Current date + 7 business days = Wednesday January 10th

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you