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,560,061
Community Members
 
Community Events
185
Community Groups

Scriptrunner behaviour - Show hide field on select.

Hi 

I have a Yes/No select box that on Yes I want to show 3 fields and on No I want to hide the fields.

scriptrunner: 4.1.3.29

Jira server: 6.4.10

With the script below when I display my ticket the helper text is displayed as expected (the current value in the field is Yes).  However when I change the value to No the helper text is removed but not displayed the fields don't change.

Any help would be appreciated.

Thanks,

Neil

=== script === 

 

log.warn("setting conditionField");
def EARequiredfield = getFieldById("customfield_14819");
def EARequirements = getFieldById("customfield_14821");
def EAStatus = getFieldById("customfield_14822");
def EAComments = getFieldById("customfield_14823");
def EARequired = EARequiredfield.getValue();

if (EARequired == "No"){
EARequiredfield.setHelpText("test: " + EARequired );
}
else {
EARequiredfield.setHelpText("test 1: " + EARequired );
}

EARequired.each { selectVal ->
if (selectVal == "No"){
EARequirements.setHidden(false);
EAStatus.setHidden(false);
EAComments.setHidden(false);
log.warn("source value: " + EARequirements.isHidden());
}
else {
EARequirements.setHidden(true);
EAStatus.setHidden(true);
EAComments.setHidden(true);
}
}

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2018

Hi @Neil Dixon

at first sight, without running this up on a test system, it looks like you are hiding fields (setHidden(true)) when flag is Yes

is that your intention?

Hi

Thanks no it wasn't my intention. I've changed the if statement and it doesn't make any difference.  Bellow is the updated script.

Neil

log.warn("setting conditionField");
def EARequiredfield = getFieldById("customfield_14819");
def EARequirements = getFieldById("customfield_14821");
def EAStatus = getFieldById("customfield_14822");
def EAComments = getFieldById("customfield_14823");
def EARequired = EARequiredfield.getValue();

if (EARequired == "No"){
EARequiredfield.setHelpText("test: " + EARequired );
}
else {
EARequiredfield.setHelpText("test 1: " + EARequired );
}

EARequired.each { selectVal ->
if (selectVal == "Yes"){
EARequirements.setHidden(false);
EAStatus.setHidden(false);
EAComments.setHidden(false);
log.warn("source value: " + EARequirements.isHidden());
}
else {
EARequirements.setHidden(true);
EAStatus.setHidden(true);
EAComments.setHidden(true);
}
}

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2018

i'll try this out on my JIRA

does the checkbox have a default value or is none allowed. Might need to check !Yes in both places

I've tried both with and without a default value.

It's a single select box not a checkbox not sure if that makes a difference.

Neil

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2018

Hi

this works in my system. 

log.warn("setting conditionField");
def EARequiredfield = getFieldById("customfield_10300");
def EARequirements = getFieldById("customfield_10301");

 

def EARequired = EARequiredfield.getValue();
log.warn("10300 " + EARequired)
if (EARequired == "No"){
EARequiredfield.setHelpText("test: " + EARequired );
}
else {
EARequiredfield.setHelpText("test 1: " + EARequired );
}
//EARequired.each { selectVal ->
if (EARequired == "Yes"){
EARequirements.setHidden(false);

log.warn("source value: " + EARequirements.isHidden());
}
else {
EARequirements.setHidden(true);
log.warn("source value: " + EARequirements.isHidden());

//}
}

I changed

EARequired.each { selectVal ->
if (selectVal == "Yes"){

to

if (EARequired == "Yes"){


I think that only works here because there is only one value 

Thanks!!

Worked just as I hoping.

Neil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events