Skip to main content
Example scripts
arrow icon
To homepage
Jira
Data centre icon
Data Center

Dynamic Text Field

Features
Behaviours
Created 1 year ago, Updated 1 month(s) ago
App in script
ScriptRunner For Jira
ScriptRunner For Jira
by Adaptavist
Compatibility
compatibility bullet
Jira (7.7 - 8.6)
compatibility bullet
ScriptRunner For Jira (5.6.14)
Language |
groovy
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

final singleSelectName = 'Some Single Select'
final textFieldName = 'Some Text Field'

def singleSelect = getFieldByName(singleSelectName)
def singleSelectValue = singleSelect.value

def textField = getFieldByName(textFieldName)

//Set the appropriate value, dependent on the value of the currently selected single select option
switch (singleSelectValue) {
//Change 'Single Select Option...' to match your single select's values.
    case 'Single Select Option 1':
        textField.setFormValue('New value for Single Select Option 1')
        break
    case 'Single Select Option 2':
        textField.setFormValue('New value for Single Select Option 2')
        break
    case 'Single Select Option 3':
        textField.setFormValue('New value for Single Select Option 3')
        break
//Reset to default value if single select option is null or any other option that is not taken care of
    default:
        textField.setFormValue("")
}
Having an issue with this script?
Report it here