Adaptavist ScriptRunner Jira Cloud - Behaviours (Regex description change)

Created by Sean Chua _Adaptavist_
 * 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." 

// Define the regex pattern to match the format "L-1234-5678"
const regex = /^L-\d{4}-\d{4}$/;

// Get the field object for "ParaTest" using its custom field ID
const paraTestField = getFieldById("customfield_xxxx");

// Function to update the field description based on the current value
function updateFieldDescription() {
    const fieldValue = paraTestField.getValue();
    if (regex.test(fieldValue.trim())) {
        paraTestField.setDescription("Correct format: L-1234-5678");
    } else {
        paraTestField.setDescription("Wrong format. Please use the format: L-1234-5678");

// Initially update the description based on the current field value (useful for edit views)

Comments (1)

  1. Linda Melson


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