Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi There,
Here is the behavior script I'm creating
script would look like this for now:
def sourcefield = getFieldById("duedate") def targetField = getFieldByName("XYZ") targetField.setRequired(false) if (sourcefield.getValue()){ targetField.setRequired(true) } else { targetField.setRequired(false) }
The field "Due Date" is a system field and there was a bug (SRJIRA-2758) where you can't get a system field form field by its name. You have to get by its ID instead:
def sourcefield = getFieldById("duedate")
However, it was fixed in ScriptRunner 6.19.0. I highly recommend for you to upgrade as there are a quite number of bugs that have been fixed from 6.12.0.
Regards, Eswar
Hi @Nag
Your code seems like "if Due Date field has no value, then XYZ will be required"
Did you try changing as below
targetField.setRequired(false)
if (sourcefield.getValue()){
targetField.setRequired(true)
}
Appreciate your quick response.
Sorry just tried, didn't work.
I just need to check if date field contains a value?
Please advise.
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.