The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.
👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.