I am trying to get the script below to work - I have tried adding it to each field in behaviours as well as on one field. The issue appears once I add the additional if statement. I have also tried this with an && statement which also breaks.
Basically - I am trying to get a field to show select options based on the values selected in the 3 fields above. I can get it to work for one field but once I add the second field via if statement or && breaks the code and nothing works.
Thanks so much for your help!
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfigImpl
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def allowedOptions = null
def fieldArcOptions = null
def fieldPlatformType = getFieldByName("Platform Type")
def valuePlatformType = fieldPlatformType.getValue().toString()
def fieldProductType = getFieldByName("Product Type (DI)")
def valueProductType = fieldProductType.getValue().toString()
def fieldClientType = getFieldByName("Client Type")
def valueClientType = fieldClientType.getValue().toString()
def fieldIntegration = getFieldByName("Integration")
def valueIntegration = fieldIntegration.getValue().toString()
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customFieldIntegration = customFieldManager.getCustomFieldObject(fieldIntegration.getFieldId())
def configIntegration = customFieldIntegration.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(configIntegration)
def issueManager = ComponentAccessor.getIssueManager()
if ((valuePlatformType.toString() == "[Bai]"))
if ((valueProductType.toString() == "Consult") || (valueProductType.toString() == "Standard") || (valueProductType.toString() == "Complex"))
if (valueClientType.toString() == "Provider") {
allowedOptions = fieldIntegration.setFieldOptions(options.findAll {
it.value in ["PPI", "Online", "Offline", "Dest", "Other"]});
}
else if ((valuePlatformType.toString() == "Bai"))
if ((valueProductType.toString() == "Consult") || (valueProductType.toString() == "Complex"))
if (valueClientType.toString() == "Buyer") {
allowedOptions = fieldIntegration.setFieldOptions(options.findAll {
it.value in ["Jrn", "S", "BPI", "Other"]});
}
else if ((valuePlatformType.toString() == "Bai"))
if ((valueProductType.toString() == "Ntar"))
if ((valueClientType.toString() == "Provider")) {
allowedOptions = fieldIntegration.setFieldOptions(options.findAll {
it.value in ["Offline", "Dest"]});
}
else if ((valuePlatformType.toString() == "Dgix") || (valuePlatformType.toString() == "Crosswise"))
if (valueProductType.toString() == "Standard")
if ((valueClientType.toString() == "Provider") || (valueClientType.toString() == "Buyer")) {
allowedOptions = fieldIntegration.setFieldOptions(options.findAll {
it.value in ["Registration", "Batch"]});
}
else if ((valuePlatformType.toString() == "Ais"))
if (valueProductType.toString() == "Standard")
if (valueClientType.toString() == "Provider") {
allowedOptions = fieldIntegration.setFieldOptions(options.findAll {
it.value in ["User Sync"]});
}
else if ((valuePlatformType.toString() == "Ais"))
if (valueProductType.toString() == "Standard")
if (valueClientType.toString() == "Buyer") {
allowedOptions = fieldIntegration.setFieldOptions(options.findAll {
it.value in ["Fose", "Roa"]});
}
else if ((valuePlatformType.toString() == "Eua") || (valuePlatformType.toString() == "Responsys"))
if (valuePlatformType.toString() == "Standard")
if ((valueClientType.toString() == "Buyer") || (valueClientType.toString() == "Provider")) {
allowedOptions = fieldIntegration.setFieldOptions(options.findAll {
it.value in ["Gool", "Private"]});
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.