Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

Is it possible to restrict the Due Date field entry to only take today's and future dates.

I need to setup the Due Date field to accept only Today's and future dates, but not past dates. Can this be done with using behavior?

I have used "Date Expression Compare" in create transition it is working in create issue screen, but our Estimated Completion Date field is editable on the view and people sometimes pick a date in the past. A validator won't help since there is no transition




3 answers

1 accepted

0 votes
Answer accepted

I tried with different code, it is working for me

// required import statements
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Date.*

// Get pointers to my date field and get its value as a date

def cf = getFieldByName("Promo End date")
def cfval = cf.getValue() as Date

// get todays date
def Promo start date = new Date()
// get yesterdays date
def yesterday = Promo start date.minus(1)

// if the date entered is before todays throw an error
if(cfval.before(yesterday)) {
cf.setError("You must not enter a date that is before todays date")
// if the date entered is over three months throw an error





This worked for me:

def duedatefield = getFieldById("duedate")
Date duedatevalue = (duedatefield.value as Date)

def today = new Date()

if(duedatevalue.getDate() < today.getDate()){
duedatefield.setError("Please select today's date or future dates")
} else{

Thanks @Kiran Talapaneni  it worked for me and i would like to have users to select the due date only 3 or more day can you suggest me.

Hi @Musku Nagaraju ,

as you assumed, you can use Behaviours to realize that. This will check the field permanantyl if the defined condition is valid. 

I try to build it very quickly, feel free to try it. (I hope duedate is the fieldId of the field)

duedatefield = getFieldById("duedate")
Date duedatevalue = (duedatefield.value as Date)

def today = new Date()

if(duedatevalue.getTime() < today.getTime()){
duedatefield.setError("your error message")
} else{

 best regards.

@Andreas Lorz ,  Thanks for you inputs but this is not working for me. 

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

import com.atlassian.jira.component.ComponentAccessor

def duedatefield = getFieldById("10701")
Date duedatevalue = (duedatefield.value as Date)

def today = new Date()

if(duedatevalue.getTime() < today.getTime()){
duedatefield.setError("Due date always feature date`")
} else{


Can we help me out to set the Promo end date always feature date of Promo start date 

e.g If I select promo start date  10-May-2019, then Promo end date should be allow post 10 th may only..

Suggest an answer

Log in or Sign up to answer