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
Thanks
Nagaraju
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
}else{
cf.clearError()
}
Thanks
Nagaraju
This worked for me:
def duedatefield = getFieldById("duedate")
Date duedatevalue = (duedatefield.value as Date)
//today
def today = new Date()
if(duedatevalue.getDate() < today.getDate()){
duedatefield.setError("Please select today's date or future dates")
} else{
duedatefield.clearError()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
//today
def today = new Date()
if(duedatevalue.getTime() < today.getTime()){
duedatefield.setError("your error message")
} else{
duedatefield.clearError()
}
best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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)
//today
def today = new Date()
if(duedatevalue.getTime() < today.getTime()){
duedatefield.setError("Due date always feature date`")
} else{
duedatefield.clearError()
}
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.