I would like to reject the option for setting the FieldA ("Fixed in version/s") filed as long as the fieldB ("Affects Version/s") field is empty
should I work with :
if (! cfValues['FieldA']) ...
how should I write it with script validator?
Thanks for your help !
Hi,
We have been able to solve similar situation to this (though customFields) by adding a script to a Scriptrunner Behaviour. Add the script to the field you want to monitor for change (in your case, add it to fieldB). Don't set any behaviour on the fieldB - the script will handle the behaviour for your fieldA
I haven't configured it by checking if is empty, just to specific values - but you probably are able to adapt it to your needs.
Remember to change "customfield_10000" with correct field-ID.
Remember to change "fieldBValue == "Yes"" to suit your needs.
The Code:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def fieldBField = getFieldById(getFieldChanged())
def fieldAField = getFieldById("customfield_10000")
String fieldBValue = fieldBField.getValue()
if (fieldBValue == "Yes") {
fieldAField.setReadOnly(true)
} else {
fieldAField.setReadOnly(false)
}
Hope this helps.
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.