Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

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
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

24 views 0 0
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