How to place a field of type list (cascade) with only one option and that the user will not be able to choose according to a certain issuetype
For example, in a project we have this cascading field named "Tribe - Squad". The first level is titled "EMSys" and the second level with two options ("Innovation" and "Sustainability").
The second level will change as per the issuetype.
Bug: It will be with the second level "Sustainability"
Wishlist: With the second level "Innovation".
We want that when the user chooses such an issuetype he will already have this field set with these options.
can you help me?
Hi Yuri,
You could use a behaviour server side script mapped to the cascading field to control the list options set based on the issue type. Below is a working script to help you get started.
import com.atlassian.jira.component.ComponentAccessor
def config = customFieldManager.getCustomFieldObject(YOUR FIELD ID HERE).getRelevantConfig(getIssueContext())
def options = ComponentAccessor.optionsManager.getOptions(config)
def cfField = getFieldById(YOUR FIELD ID HERE)
if(issueContext.issueType.name == "Bug"){
def parentOption = options.find{it.value in "EMSys"}
def childOption = parentOption?.childOptions.find{it.value in "Sustainability"}
cfField.setFormValue([parentOption.optionId,childOption.optionId])
}else if(issueContext.issueType.name == "Wishlist"){
def parentOption = options.find{it.value in "EMSys"}
def childOption = parentOption?.childOptions.find{it.value in "Innovation"}
cfField.setFormValue([parentOption.optionId,childOption.optionId])
}
You could also set this field to be read only adding cfField.setReadOnly(true) to the script if you didn't want users to be able to modify the preset value. I'd recommend referring to the API quick reference for the available behaviour methods.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.