Hi,
I try to have a behaviour who block ticket creation/Edition if a date2 (Ending date) is inferior to date1 (Starting date).
I use the following code but It look like working during few day.
import groovy.transform.BaseScript
def startDateField = getFieldByName("onCall start date")
def startDateValue = startDateField.getValue() as Date
def dueDateField = getFieldByName("onCall end date")
def dueDateValue = dueDateField.getValue() as Date
startDateField.clearError()
dueDateField.clearError()
strErrorText = "onCall end date must be greater than onCall start date"
if (dueDateValue != null && startDateValue != null ){
if(startDateValue > dueDateValue){
startDateField.setError(strErrorText)
dueDateField.setError(strErrorText)
}
}
Some user are complaining because they can't validate the ticket with correct date (Date2 was superior to date1). I think I have done something wrong.
Could you help me?
Regards,
Mickael O.
If I understood correctly your script does not validate the fields all the time as expected
if so, it matters what field you mapped with script(I believe you placed this as server side script). because script will be executing whenever the associated field is updated/changed
e.g.: you mapped this script with Date2 then
I updated Date2 first (script runs here and found Date1 is empty so doesn't validate anything)
then I update Date1(script won't be executing again)
To avoid this issue. create one more behaviour and map it to Date1 with same script
BR,
Leo
Thank you Leo. I'll try it and I come back to you.
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.