I have 2 select list ( single choice ) custom fields.
Custom Field1 is countries i.e Germany,France,Italy
Custom Field2 is cities i.e. Köln,Berlin,Paris,Monaco,Milano,Roma
I want to display only Milano and Roma when Custom field 1 is selected as Italy.
I do not use Cascaded Custom Fields, these two fields are distinct.
How can I do that, probably with Scriptrunner Behaviors ?
Thanks in advance !
This Is the code Can You Try This Is Working Script Behaviour
import com.atlassian.jira.component.ComponentAccessor
def storeName = getFieldByName("Store Name")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(storeName.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
if (getFieldById(getFieldChanged()).getValue()!=null){
String val=getFieldById(getFieldChanged()).getValue() as String
switch(val){
case"7":
def optionToSelect = options.findAll { it.value in ["HAMDAN STREET STORE"] }
storeName.setFormValue("HAMDAN STREET STORE")
storeName.setFieldOptions(optionToSelect)
break
case"9":
def optionToSelect = options.findAll { it.value in ["AL AIN STORE"] }
storeName.setFormValue("AL AIN STORE")
storeName.setFieldOptions(optionToSelect)
break
}}
I think you should create a scripted field for Custom field 2 for reflecting the changes depends on custom field 1
eg.
1 ) Download Script Runner Plug in.
2 ) Create a "Scripted Field" Custom field
3) Go to Admin >> Script Field>> Edit the custom field which you have
recently created.
4 ) Below is an example which select the value from select custom field and
push it the same to Scripted field.
eg code : -
here I am returning the value of Select custom field to sctipted field.
def select = getCustomFieldValue("Select")
if (select) {
return select
}
else {
return null
}
// This script return the value which you have selected in Select custom field, instead you can
// redefine the code as per your requirement.
Cheers
PVS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.