How can i set the Request type according to the issuetype

Estevão Basso Chrisostimo Soares
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 29, 2024

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: []

1 answer

0 votes
Carla Ann Rowland
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2024

In Service Management a Customer Request Type can be attached to the same issue type so my question is each Customer request type in your project have a unique issue type?

 

Use case example:

Need help with printer--- Service Request issue type

Need help with password --- Service Request issue type

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events