Initialize min value of datepicker in customer portal

Julien REBILLARD June 7, 2021

Hello,
I am looking for a solution in order to be able to enter the minimum value of a datepicker (due date) when the customer create a request in the customer portal.

If possible without going through a validator, I would like the datepicker to be grayed out on certain date ranges. With scriptrunner behaviours ?

Thank you in advance for your help

1 answer

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 15, 2021

You can't make the dates grey or block them in any way (plus dates can alse be entered by typing).

But with a behaviour script, you can validate the date as soon as it's selected and raise an error if it's not valid.

Something along these lines:

import groovy.time.TimeCategory
def
field = getFieldById(getFieldChanged())
field.clearError()
def date = field.value
if(date)
date.clearTime() //ignore the time of day
def today = new Date().clearTime()
use(TimeCategory) {
if (date.before(today.plus(14.day))) {
field.setError("The due date can not be in the next 14 days")
}
}
}

Be careful to only apply this with portal mapping. Or else if you try to edit the issue after the due date, you will be forced to change the due date to 2 weeks in the future. But since portal configurations are only applicable on create screen, it won't be a problem.

Suggest an answer

Log in or Sign up to answer