I'm trying to create a script in Behaviour which according to the issuetype, the request type is setted, or at least the other options get hidden. I've tried this one with a custom field type select option and it works correctly, but when I changed to run in Request type field, i got nothing.
--------------------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
final singleSelectListName = 'Request type'
[singleSelectListName].each { selectFieldName ->
// Get the select field
def selectField = getFieldByName(selectFieldName)
log.warn("$selectFieldName")
log.warn(getFieldByName(singleSelectListName))
// Getting select field options
def selectCustomField = customFieldManager.customFieldObjects.findByName(selectFieldName)
def selectConfig = selectCustomField.getRelevantConfig(issueContext)
def selectOptions = ComponentAccessor.optionsManager.getOptions(selectConfig)
// Log select options
log.warn("Select Options for $selectFieldName: $selectOptions")
// Filter select available options
final selectAvailableOptions = selectOptions.findAll { it.value in ['Termo de devolução de equipamento'] }
selectField.setFieldOptions(selectAvailableOptions)
// Log select available options
log.warn("Select Available Options for $selectFieldName: $selectAvailableOptions")
// Set the default values depending on select type
// if (selectFieldName == singleSelectListName) {
// def defaultValue = selectAvailableOptions.find { it.value == 'Termo de devolução de equipamento' }
// selectField.setFormValue(defaultValue.optionId)
// log.warn("Default Value for $selectFieldName: $defaultValue")
// }
}
-----------------------------------------------------------
Here is the log that I got when test it:
2024-02-29 10:05:43,368 WARN [runner.ScriptBindingsManager]: Request type 2024-02-29 10:05:43,368 WARN [runner.ScriptBindingsManager]: Form field ID: customfield_15100, value: null 2024-02-29 10:05:43,374 WARN [runner.ScriptBindingsManager]: Select Options for Request type: [] 2024-02-29 10:05:43,375 WARN [runner.ScriptBindingsManager]: Select Available Options for Request type: []
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.