I have the below script & it behaves the below mentioned way,
* Makes a drop-down field mandatory when the current Epic Due Date value is changed to a latter date
* Makes the drop-down field mandatory when the Epic Due Date value is completely erased
* Hides drop-down field when the current Due Date value is changed to a earlier date
* Stays hidden when an user randomly edits an Epic issue for other field values
But the problem I have is, sometimes an user creates a new Epic without a Due Date value (Maybe they wanna add a date after sometime) . And even in that case, when they try to fill Due Date for the first time, the Reason drop-down field becomes mandatory. Is it possible to avoid in that scenario alone ? (like, when an user already created an Epic & tries adding the Due Date for the first time, I want the field to be hidden ?)
Hi @Aisha M,
you can simply place another condition to check Due Date's value. if it was null and gets value now you don't need to perform any changes, something like below
if (underlyingIssue){
def dueDate_value = underlyingIssue?.getDueDate()
if(dueDate_value){
def duedate = getFieldById("duedate").formValue
def textField = getFieldById("customfield_10002")
if (duedate != "" && dueDate_value >= duedate){
textField.setHidden(true)
textField.setRequired(false)
}
else {
textField.setHidden(false)
textField.setRequired(true)
}
}
}
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Leo Yes, the text field did not become mandatory when the Due Date was changed to a latter value from the existing date. Infact, nothing happened once I replaced my code as below with the above mentioned snippet.
import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours
import java.sql.Timestamp
@BaseScript FieldBehaviours fieldBehaviours
if (underlyingIssue){
def dueDate_value = underlyingIssue?.getDueDate()
if(dueDate_value){
def duedate = getFieldById("duedate").formValue
def textField = getFieldById("customfield_10002")
if (duedate != "" && dueDate_value >= duedate){
textField.setHidden(true)
textField.setRequired(false)
}
else {
textField.setHidden(false)
textField.setRequired(true)
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.