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.