Behaviours marks field readonly while date menu is open

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

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.

 

Thank you.  We were afraid of that.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,343 views 13 19
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you