Versions Compared

Key

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

Abstract

This code snippet checks the value of a standard or custom multi-valued type field (typically a multi-select field). The multi-valued fields can either be a collection of objects or a set of values.

...

Code Block
languagegroovy
linenumberstrue
//Run a loop on all the selected options of the field and find the desired option
return (issue.get("<Name of the field>").find any{
  it.getValue() == "<Value of the field>"} != null)
Placeholders
PlaceholderDescriptionExample
<Name of the field>

Name of the multi-select field

Checkboxes

<Value of the field>Value of the option

Verification done

...

Code Block
languagegroovy
linenumberstrue
//Run a loop on all the selected options of the field and find for the desired object
return (issue.get("<Name of the field>").findany {
  it.getName() == "<Name of the desired version>"} != null)
Placeholders

Placeholder

Description

Example

<Name of the field>Name of the multi-valued version fieldfixVersions
<Name of the desired version>Name of the version to find2.0

...

Code Block
languagegroovy
linenumberstrue
//Run a loop on all the selected labels of the field and find for the desired label
return (issue.get("<Name of the field>").findany {
  it.getLabel() == "<Desired label>"} != null)
Placeholders

Placeholder

Description

Example

<Name of the field>Name of the labels fieldlabels
<Desired label>Label to findUse-case

...

The output of the code is a boolean value (true or false) which you could use to conditionally execute a Post-function/Condition/Validator or Unlink issues:

  • Check the issue has been flagged

    Code Block
    languagegroovy
    linenumberstrue
    return (issue.get("Flagged").findany {
      it.getValue() == "Impediment"} != null)


  • Check the issue has a label Server

    Code Block
    languagegroovy
    linenumberstrue
    return (issue.get("Labels").findany {
      it.getLabel() == "Server"} != null)


  • Check the issue has 5.0.0 as an Affects Version/s

    Code Block
    languagegroovy
    linenumberstrue
    return (issue.get("versions").findany {
      it.getName() == "5.0.0"} != null)


References

...