Hi, I am trying to create a simple behaviour that gives an error when the user edits an issue and doesn't update the "Location" multi-select field away from "(Not yet set)" value. The problem with my code here is that when the user changes the value in the form to a valid option, it still gives me the error. It's not picking up the changed form value. Do you know how to fix this? Thanks.
def requiredField = getFieldByName("Location")
if ("(Not yet set)" in requiredField.value) {
requiredField.setError("Location is not yet set.")
}
Hi @Paul Stahlke,
You are still getting the error message even though the value is set because you haven't set a clearError() option for the field.
You should try something like:-
def requiredField = getFieldByName("Location")
requiredField.clearError()
if ("(Not yet set)" in requiredField.value) {
requiredField.setError("Location is not yet set.")
}
Also, if you have configured this for the Location field, i.e. as a Server-Side Behaviour, the better option would be to set the code as:-
def requiredField = getFieldById(fieldChanged)
requiredField.clearError()
if ("(Not yet set)" in requiredField.value) {
requiredField.setError("Location is not yet set.")
}
I hope this helps to answer your question. :)
Thank you and Kind regards,
Ram
This is fantastic, Ram! Thanks very much. Adding the clearError() line fixed it perfectly. The second option with getFieldById(fieldChanged) works nicely as well. How does that method make it better?
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.