Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

Abstract

This code snippet sets a Checklist/Multi-select type field with a subset of the available options based on a regular expression

Logic

Access the available options of the Checklist/Multi-select type field and retain all the options that match the regular expression.

Snippet

Code Block
languagejs
linenumberstrue
def regExp = ~/^(?i).*<Text to match in the option>.*/
issue.getAvailableOptions("<Name of the field>").findAll{
  it.getValue().matches(regExp)
}

Placeholders

PlaceholderDescriptionExample
<Name of the field>Name of the field of type Checkboxes/Select list(multiple choices)Tasks list
<Text in the option>Text the options must contain to be selectedInstallation

Examples

The output of the code is Collection<Option> which you could use in a Groovy expression, for example to - Set a Checkboxes/Multi-select field with a subset of its available options. Eg: Select all the Installation tasks in the Checkboxes/Multi-select type field in

  • one of the Set Field Value post-functions
  • the Create issue post-function under Set fields of new issue section

    Code Block
    languagegroovy
    linenumberstrue
    def regExp = ~/^(?i).*installation.*/
    issue.getAvailableOptions("Installations list").findAll{
      it.getValue().matches(regExp)
    }



References

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "jmwe-nunjucks" and type = "page" and space = "KB"
labelsjmwe-nunjucks jmwe-cloud

...