Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,360,197
Community Members
 
Community Events
168
Community Groups

When someone choose one option from single select list then in few option should be visible

I have two single select dropdown menu custom field called

Custom field one= Product ( I have 9 options under this list)

Custom field two= Component

So now when someone select Infrastructure from Product then in Component List I want to see the following options; Automation, testing, developing, other.

 

I am using behavior from script runner but it seems not to be working for me.

Can you please guide me with this?

1 answer

0 votes
Antoine Berry Community Leader Aug 08, 2022

Hello @Sonal Sharma ,

Please create a behaviours and link it to the Product field, and use this script (please update the custom fields ids) : 

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor


def optionsManager = ComponentAccessor.getOptionsManager()
def productId = 11001
def componentId = 11002


def productField = getFieldById("customfield_"+productId)
def productFieldValue = productField.getValue()

def componentField = getFieldById("customfield_"+componentId)

def component = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(componentId)

def componentConfig = component.getRelevantConfig(getIssueContext())
def componentOptions = optionsManager.getOptions(componentConfig).findAll { !it.getDisabled() }

def componentList = ["Automation","testing","developing","others"]
def componentsOptionsMap = componentOptions.findAll()

if ((productFieldValue == "Infrastructure") || ("Infrastructure" in productFieldValue)){
componentsOptionsMap = componentOptions.findAll{ it.value in componentList }
}

componentField.setFieldOptions(componentsOptionsMap)

Let me know if that works.

Antoine Berry Community Leader Aug 10, 2022

Hello @Sonal Sharma ,

Have you been able to try this script ?

@Antoine Berry Thanks for the support but it is not working for me, I don't see any changes in the behavior. 

Antoine Berry Community Leader Sep 21, 2022

@Sonal Sharma Could you find anything in the logs ?

Suggest an answer

Log in or Sign up to answer