Creating a read only due date field that auto populates when creating an issue

With different issue types we have put in place different SLA's. I want JIRA to manage the due dates for the SLA's based on issue type. For example when someone creates an issue with issue type Question the SLA to answer this question and resolve the issue is 3 days from the issue being created. I want the field to display in the issue but not allow it to be edited by anyone in jira-users other than people in jira-administrators group.

I have tried using the read only text field and then try to configure it somehow to auto populate but could not work out how.

Any help you could give would be greatly appreciated.

Thanks, Andrew

2 answers

1 accepted

2 votes
Accepted answer

You will need to create a post function or a post function groovy script with script runner plugin which will check the issue type and set the Due date of the Issue , Also you will need to make the due date field as read only for this you can use the behaviours plugin which can make a field as read only .

Refer the below groovy script example for setting the due date

import java.sql.Timestamp
import com.atlassian.jira.issue.MutableIssue
// initializing the priority
def BLOCKER = 1;
def CRITICAL = 2;
def MAJOR = 3;
def MINOR = 9;
def Trivial = 30;
// calender which returns the date according to the priority defined
private GregorianCalendar getDate(double roll){
        Calendar cal = Calendar.getInstance();
        for (int x=0;x<roll;x++){
        return cal;
MutableIssue mutableIssue = (MutableIssue) issue;
def priority = mutableIssue.getPriority().getString("name");
def setDueDate = mutableIssue.getDueDate();
 //only set the dueDate if the date isn't already set (i.e. if it == null).
        GregorianCalendar cal;
                cal = getDate(CRITICAL);
        } else if(priority.equals("Major")){
                cal = getDate(MAJOR);
        } else if(priority.equals("Minor")){
                cal = getDate(MINOR);
        Timestamp dueDate = new Timestamp(cal.getTimeInMillis());

Also refer this post for making a field read only

In this case, you need to define the condition in the above script based on Issue Type and not on Priority

def issueType = mutableIssue.getIssueType().getString("Question");

So the above script can be modified to the below one and run it as a post function by adding this script to the Create Issue transition-

def BUG = 1; 
def TASK = 2; 
def QUESTION = 9; 

	cal = getDate(BUG);         
else if(issueType.equals("Task"))
	cal = getDate(TASK);         
else if(issueType.equals("Improvement"))
	cal = getDate(IMPROVEMENT);         
else if(issueType.equals("Question"))
	cal = getDate(QUESTION);

Thanks Mizan. Much appreciated

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Statuspage

194 years of downtime: looking back on incident data from 2018

Statuspage customers logged more than 194 years of collective incidents in 2018. That’s a whopping 87% increase from the  104 years logged in 2017 , and we aren’t even through December yet....

56 views 1 5
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