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

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
Mizan Community Champion Dec 17, 2012

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 Join to answer
Community showcase
Louis De Jaeger
Posted Thursday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

187 views 12 3
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
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