Hi!
I have a multiselect field with over 70 options. And for each option chosen I need to show extra field on portal.
I made a script look like:
import com.onresolve.jira.groovy.user.FormField
import org.apache.log4j.Level
import org.apache.log4j.Logger
Logger log = Logger.getLogger("Software Logger")
log.setLevel(Level.DEBUG)
def soft = getFieldByName("Enterprise Software") //multiselect
FormField passwordSoft = getFieldByName("1Password Licences") //text
FormField adobeAcrobatSoft = getFieldByName("Adobe Acrobat Pro Licences") //text
FormField adobeCreativeSoft = getFieldByName("Adobe Creative Cloud Licences") //text
def softValue = soft.value as List
log.debug("${softValue}")
if (softValue.toString().contains("1Password")) {
setNotHiddenAndRequired([passwordSoft])
setHiddenAndEmpty([adobeAcrobatSoft, adobeCreativeSoft, adobeIllustratorSoft, adobePhotoshopSoft, charlesProxySoft, dockerSoft,
figjamSoft, figmaSoft])
}
if (softValue.containsIgnoreCase("Adobe Acrobat Pro")) {
setNotHiddenAndRequired([adobeAcrobatSoft])
setHiddenAndEmpty([ adobeCreativeSoft, adobeIllustratorSoft, adobePhotoshopSoft, charlesProxySoft, dockerSoft,
figjamSoft, figmaSoft, passwordSoft])
}
else {
setHiddenAndEmpty([adobeAcrobatSoft, adobeCreativeSoft, adobeIllustratorSoft, adobePhotoshopSoft, charlesProxySoft, dockerSoft,
figjamSoft, figmaSoft, passwordSoft])
}
private void setHiddenAndEmpty(Collection<FormField> fields){
fields.each{ it.setHidden(true) }
fields.each{ it.setRequired(false) }
fields.each{ it.setFormValue(null) }
}
private void setNotHiddenAndRequired(Collection<FormField> fields){
fields.each{ it.setHidden(false) }
fields.each{ it.setRequired(true) }
}
And many more if. But it only works with one if. Others are just ignored. Is there a way to work with List, make massive Map or just any idea will work.
Thanks!