I want to hide a field, depending on the value of another field. This works for exact matches using ==
But what about a multiple select list? I want to express:
- if field A contains value "Client", then show field B (this works with ==)
- if field A contains value "Press", then show field C (this works with ==)
- if field A contains values "Client" and "Press", then show field B and C (does not work with ==)
- if field A contains values "Press" and "blablabla", then show field C (does not work with ==)
So I want to use contains and tried something like this:
import com.atlassian.jira.component.ComponentAccessor
def fieldA= getFieldById("customfield_16044")
def fieldB = getFieldById("customfield_18340")
def fieldC = getFieldById("customfield_18341")
def Clientstring = "Client"
def Pressstring = "Press"
log.debug("dropdown value" + fieldA.getValue())
if (fieldA.getValue().contains(Clientstring)){
fieldB.setHidden(false);
fieldC.setHidden(true);
} else
if (fieldA.getValue().contains(Pressstring)){
fieldB.setHidden(true);
fieldC.setHidden(false);
}
But line (fieldA.getValue().contains(Clientstring)) results in error:
[Static type checking] - Cannot find matching method java.lang.Object#contains(java.lang.String). Please check if the declared type is correct and if the method exists.
Possible solutions: toString(), toString(), notify()