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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.