I have 2 fields( select list single choice ) named A and B .
A and B contains so many values as well .
My request is if A field is selected with a value XM then the field B should shows only some selected values ( not all values ).
How can I acheive this ?
Hi @Aswathi D
You can do it by creating a Behaviour that is part of Scriptrunner app.
https://scriptrunner.adaptavist.com/6.20.0/jira/behaviours-overview.html
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aswathi D please find below an example.
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
final singleSelectListName = 'Select List'
def radioButton = getFieldById(getFieldChanged())
def allowedValues
if(radioButton.getValue() == 'A'){
allowedValues = ['1', '2']
}
if(radioButton.getValue() == 'B'){
allowedValues = ['3']
}
if(allowedValues){
// Getting select field options
def selectCustomField = customFieldManager.customFieldObjects.findByName(singleSelectListName)
def selectConfig = selectCustomField.getRelevantConfig(issueContext)
def selectOptions = ComponentAccessor.optionsManager.getOptions(selectConfig)
// Filter select available options
final selectAvailableOptions = selectOptions.findAll { it.value in allowedValues }
getFieldByName(singleSelectListName).setFieldOptions(selectAvailableOptions)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I have a more or less similar request.
I need to restrict the displayed values of a field. However, there is a difference. I don't have another defining field. Instead, I need to restrict the field values to "A" and "B" only on a transition screen.
Unfortunatelly I don't have scripting skills. Can someone please help with this?
Big thanks in advance!
Best regards,
André
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.