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

Checkboxes with Behaviours

Michiel Bakker December 14, 2022

Hello!

This is my situation. I want to go to the next question (Question 5) if one of the questions (4.1, 4.2 or 4.3) have the checkbox "Yes". So when 1 of them is being checked with Yes it have to go to question 5. The rest of the questions don't have to be answered then.

Could you please help me?

JiraCheckbox.PNG

Thanks for the help!

3 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 23, 2022

What do you mean by "go to the next question"?  

Michiel Bakker December 29, 2022

When you go to the form question 4.1 pops up. When you answer "Yes" the other questions (4.2 and 4.3) are no longer relevant and you jump to question 5.
If 4.1 is answered with "No" question 4.2 pops up. Then the same happens, if 4.2 is "Yes" jump to question 5, if "No" question 4.3 pops up.

Hope this is helpfull and you can support me with the code ;)

0 votes
Dante Labate January 6, 2023

@Michiel Bakker  

in behaviors, in the issuetype field, set to hide the fields of questions 4.2, 4.3 and 5.

def question_41 = getFieldById("customfield_XXXX")
question_41.setHidden(false).setRequired(true)

def question_42 = getFieldById("customfield_XXXX")
question_42.setHidden(true).setRequired(false)

def question_43 = getFieldById("customfield_XXXX")
question_43.setHidden(true).setRequired(false)

def question_5 = getFieldById("customfield_XXXX")
question_5.setHidden(true).setRequired(false)

 this way the creation screen will be loaded showing only question 4.1 on the screen (the others will be hidden)

 

again in behaviours, now in the field of question 4.1, configure it to display only 4.2 if the answer is no and display 5 if the answer is yes.

def question_41 = getFieldById("customfield_XXXX")
def question_42 = getFieldById("customfield_XXXX")
def question_43 = getFieldById("customfield_XXXX")
def question_5 = getFieldById("customfield_XXXX")

if (question_41.getValue == "No"){
question_42.setHidden(false).setRequired(true)
}

if (question_41.getValue == "Yes"){
question_5.setHidden(false).setRequired(true)
}

 

use practically the same code in the question field 4.2 changing only the reference field in ifs

def question_41 = getFieldById("customfield_XXXX")
def question_42 = getFieldById("customfield_XXXX")
def question_43 = getFieldById("customfield_XXXX")
def question_5 = getFieldById("customfield_XXXX")

if (question_42.getValue == "No"){
question_43.setHidden(false).setRequired(true)
}

if (question_42.getValue == "Yes"){
question_5.setHidden(false).setRequired(true)
}

 

in question 4.3 if you answer "No" nothing happens, but if you answer "Yes" it displays the field of question 5.

def question_41 = getFieldById("customfield_XXXX")
def question_42 = getFieldById("customfield_XXXX")
def question_43 = getFieldById("customfield_XXXX")
def question_5 = getFieldById("customfield_XXXX")


if (question_43.getValue == "Yes"){
question_5.setHidden(false).setRequired(true)
}  

 

remember to change the customfield_XXXX to the correct id of your field. 

0 votes
Michiel Bakker December 19, 2022

Anyone? :)

Dante Labate January 5, 2023

see if it works for you

Michiel Bakker January 26, 2023

Hello Dante!

Thank you very much for your script! 

I have still a problem to get it working perfectly. 

Questions 4.1, 4.2 and 4.3 are configured as required. This because otherwise the option "none" is beeing displayed as one of the options (besides Yes an No).

When i configure the code below (example for only 4.2 question) for the questions 4.2 and 4.3 the questions are still required despite configurations says .setRequired(false)

def question_41 = getFieldById(getFieldChanged()).getValue().toString()
def question_42 = getFieldById(getFieldChanged()).getValue().toString()
def question_43 = getFieldById(getFieldChanged()).getValue().toString()

if (question_42 == "Yes") {
    getFieldById("customfield_14709").setHidden(true).setRequired(false)
}

if (question_42 == "No") {
    getFieldById("customfield_14709").setHidden(false).setRequired(true)
}
Do you know what is going wrong?
TAGS
AUG Leaders

Atlassian Community Events