Hello,
I' I'm looking for a script to validate dates in my create transition. The usecase is:
if today is friday then the target date must be at least the next tuesday.
any ideas?
thanks in advance :)
Sure... simple enough...
User a simple scripted validator with this script:
def today = new Date()
today.day != 5 || cfValues['Target Date'] > today.clearTime() + 4
This will be true if either:
When the validator is true, the transition is allowed.
When the validator is false (both conditions above are false at the same time), then you specify the error message to display on the Target Date field
Hey Peter,
I tried your script but it doesn't work for me. I think I need to be more specific and my usecase changed a bit...
Target date must be apart 2 days from created date (example: created date = monday than target date can't be either the same day nor the next day). Additionally, if created date is a friday target date must at least the next tuesday.
thanks in advance :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then my guess is that if Created Date is a Thursday then the target date must be the next Monday?
If so, that's how I would do it:
def today = new Date()
def minDate = today.clearTime() +2
if(today.day in [4,5,6]){
//on thursday, friday or saturday add 2 days to account for the weekend
minDate = minDate+2
}
cfValues['Target Date'] > minDate
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.