Behaviours marks field readonly while date menu is open

Kevin Dalton February 28, 2017

We have a behaviour script

import java.text.SimpleDateFormat
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.datetime.DateTimeFormatterFactory
import com.atlassian.jira.datetime.DateTimeStyle
def oDate = getFieldById("customfield_16324").getValue()  as Date
def eDate = getFieldById("customfield_16325").getValue()
def dateTimeFormatterFactory = ComponentAccessor.getComponentOfType(DateTimeFormatterFactory)
def formatter = dateTimeFormatterFactory.formatter().forLoggedInUser().withStyle(DateTimeStyle.DATE_PICKER)
def formatteddate = formatter.format(oDate)
if ( ! eDate ) {
getFieldById("customfield_16325").setFormValue(formatteddate)
}
if ( oDate != null) {
getFieldById("customfield_16324").setReadOnly(true)
} else {
getFieldById("customfield_16324").setReadOnly(false)
}

And when we are entering the date field and switching months the field populates while we switch months thus locking the field and setting the value of the next field we copy it to.  Is there a way to ensure that the script does not execute until a value is entered in the field and the menu is not open to change months.

2 answers

0 votes
Kevin Dalton March 1, 2017

Thank you.  We were afraid of that.

0 votes
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2017

Hi Kevin, 

I see what you mean. I am afraid that there is not an easy solution in that case. I suppose the best solution was to check the oDate for a specific month or date, instead of just checking for a value.

 

Suggest an answer

Log in or Sign up to answer