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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

221 views 1 18
Join discussion

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