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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,921
Community Members
 
Community Events
176
Community Groups

Checkboxes with Behaviours

Edited

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

0 votes
Answer accepted

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

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 ;)

@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. 

Anyone? :)

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?

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events