It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

If Statements to alter select field options Jira Behaviours

bSte Jan 22, 2019

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"]});
}

0 answers

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar alert! An IT Admin's Guide to Securing Collaboration at Scale

Hello, Atlassian Community! My name is Dave Meyer and I'm a Principal Product Manager at Atlassian. I wanted to give this community a heads up about an upcoming Webinar that might be of interest...

165 views 2 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you