You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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);
}
}
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);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.