Hi Team,
I am trying to create a script that shows or hides a single line text field called "Reason for the Due Date" based on the value of a date field called "Due Date". Although the script is working, the "Reason for the Due Date" field is visible when the ticket is initially created, even when the "Due Date" field is blank. Ideally, the "Reason for the Due Date" field should only be visible when a value is entered in the "Due Date" field and should disappear when the "Due Date" field is blank.
On Create :

import com.onresolve.jira.groovy.user.FieldBehaviours
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def log = Logger.getLogger(getClass())
// Set log level
log.setLevel(Level.DEBUG)
def dueField = getFieldByName("Due Date")
def reasonField = getFieldByName('Reason for the Due Date')
def dateFieldValue = dueField.getValue() as Date
if (dateFieldValue == null)
{
reasonField.setHidden(true)
reasonField.setRequired(false)
}
else
{
reasonField.setHidden(false)
reasonField.setRequired(true)
}