Hi All, I'm trying to make two fields appear for editing, if the 'Planned' date is before the 'Actual' date.
Fields:- 'Reason for Delay' (Dropdown)
'Explanation of Delay' (Free form text).
Is there a way using ScriptRunner and 'Field Behaviours' that I could code the Server side condition to represent this?
Thanks.
Hello Karl samson,
you can use behaviours in script runner Create a New Behaviour select the project and issue type.
Add Fields to the Behaviour:
Add the ‘Planned’ date, ‘Actual’ date, ‘Reason for Delay’, and ‘Explanation of Delay’ fields to the behaviour use the code
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
@BaseScript FieldBehaviours behaviours
def plannedDateField = getFieldByName("Planned Date")
def actualDateField = getFieldByName("Actual Date")
def reasonForDelayField = getFieldByName("Reason for Delay")
def explanationOfDelayField = getFieldByName("Explanation of Delay")
def plannedDate = plannedDateField.getValue() as Date
def actualDate = actualDateField.getValue() as Date
if (plannedDate && actualDate && plannedDate.before(actualDate)) {
reasonForDelayField.setHidden(false)
reasonForDelayField.setRequired(true)
explanationOfDelayField.setHidden(false)
explanationOfDelayField.setRequired(true)
} else {
reasonForDelayField.setHidden(true)
reasonForDelayField.setRequired(false)
explanationOfDelayField.setHidden(true)
explanationOfDelayField.setRequired(false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.