Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner Behaviours - Optional labels do not disappear for required checkboxes custom fields

Hi community,

I am showing/hiding fields in my Jira Service Desk requests using ScriptRunner Behaviours.

When those fields are visible, they should be required.

def triggerField = getFieldById("customfield_11227")
def hiddenField = getFieldById("customfield_11228")

def isSelected = ((String)triggerField.getValue())?.contains("Oui")

if (isSelected){
    hiddenField.setHidden(false)
    hiddenField.setRequired(true)
}
else{
    hiddenField.setHidden(true)
    hiddenField.setRequired(false)
}

It works well with most custom fields:

  1. The (optional) label next to the field disappears when the field becomes visible
  2. There is an error message when trying to save with the field not defined

But it does not work when the custom field is a Checkboxes custom field:

  1. The (optional) label next to the field do not disappear when the field becomes visible
  2. There is an error message when trying to save with the field not defined, and the (optional) label disappears only at that moment (after submitting)

What could explain this different behaviour of Behaviours? ;-)

Thanks for your help!
Cheers,

David

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

461 views 5 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you