...
...
...
...
Abstract
This code snippet sets a Checklist/Multi-select type field with certain a subset of the available options based on the name of the option.a regular expression
Logic
Access the available options of the Checklist/Multi-select type field and find for options with the specific text.
...
retain all the options that match the regular expression.
Snippet
Code Block | ||||
---|---|---|---|---|
| ||||
def regExp = ~/^(?i).*<Text to match in the option>.*/ issue.getAvailableOptions("<Name of the field>").findAll{ it.getValue().contains("<Text in the option>"matches(regExp) } |
Placeholders
Placeholder | Description | Example |
---|---|---|
<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 selected | Installation |
Examples
...
language | js |
---|---|
linenumbers | true |
...
Context
The output of the code is a Collection<Option> a 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-functionsone of
the
Transition issue post-functions on the transition screens, if anytheCreate issue post-function under Set fields of new issue section
- To include the Checkboxes/Multi-select field values in the
- Comment in one of the Comment issue post-functions
- Subject/HTML body/Text body of Email issue post-function
- JQL search expression of Link issues current to issue
- In a conditional execution script to
- Run a post-function
- Run a condition
- Run a validator
- Unlink issues
Use cases
A typical use case would be to select the Installation tasks in the Checkboxes/Multi-select type field when all the Installations are done.
...
Code Block language groovy linenumbers true def regExp = ~/^(?i).*installation.*/ issue.getAvailableOptions("Installations list").findAll{ it.getValue().matches(regExp) }
References
- Variables used in a Groovy expression
- Issue interface
- Accessing a field of Checkboxes/Multi-select type
- Groovy Documentation
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...