Snippets

Adaptavist ScriptRunner Cloud - Behaviour - Make Select List Field Required when specific value selected in a Multi Select List Field

Created by Kristian Walker last modified
/*
 * This script provides an example of how in Behaviours to make a Select List field required when a specific value is selected inside a Multi 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." 
*/ 


// Change below to the Name of your Multi Select list field 
const mutiSelectFieldName = "Demo Multi Select"

// Change below to the ID of your  Select list field 
const selectListField = getFieldById("customfield_10072");

// Access the changed Field Value
const changedField = getChangeField()

// If changed field is the Multi Select Field and Option A selected
if (changedField.getName() === mutiSelectFieldName
    && changedField.getValue().some(item => item.value === "A")) { // Change "A" here to the value in your Multi Select List Field that must be selected 

    // Make the Select list field required
    selectListField.setRequired(true);

} else {
    // Make the Select list field optional when A not selected
    selectListField.setRequired(false);
}



Comments (0)

HTTPS SSH

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