Snippets

Adaptavist Behaviours Jira Cloud Set Value of Select List Field to a Text Field

Created by Kristian Walker
/*
 * This script provides some example code that can be run on the Create View and On Change event in Behaviours in order to populate a text field with the value selected in a Select List Field.
 * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner 
 * license shall be granted a  non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed
 * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." 
*/


// Get the field that changed on screen
const changedField = getChangeField();

// get text field
const textField = getFieldById("customfield_10090"); // Change to ID of your single line text field here. 

// Check if the changed field is a select list 
if(changedField.getType() == "com.atlassian.jira.plugin.system.customfieldtypes:select"
    && changedField.getName() == "Demo Select List" // Change to name of your select list field here
    && changedField.getValue() !== null ) {

    textField.setValue(changedField.getValue().value.toString())

}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.