Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Checking the value of a multi-valued field

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 an array of objects or an array of values.

Logic

Iterate over the array of objects or values and check a specific field for the required value.

Snippet

For multi-select fields:

{# Checks if a specific option is selected #}
{{ issue.fields["<Name of the field>"] | find({"value":"<Value of the desired option>"}) != null }}
Placeholders

Placeholder

Description

Example

<Name of the field>Name of the multi-select fieldCheckboxes
<Value of the desired option>Value of the option.Verification done

For multi-versions/users/components/groups fields (e.g. Fix Version/s):

{# Checks if a specific version is selected #}
{{ issue.fields["<Name of the field>"] | find({"name":"<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

For Labels field:

{# Checks if a specific label is present #}
{{ issue.fields["<Name of the field>"] | find("<Desired label>") != null }}
Placeholders

Placeholder

Description

Example

<Name of the field>Name of the labels fieldLabels
<Desired label>Label to findNew

Examples

The output of this snippet is a boolean value (true or false) which you could use to conditionally execute a Post-function or Unlink issues:

  • Check the issue has been flagged

    {{ issue.fields["Flagged"] | find({"value":"Impediment"}) != null }}
  • Check the issue has a label Server

    {{ issue.fields["Labels"] | find("Server") != null }}
  • The issue has 5.0.0 as an Affects Version/s

    {{ issue.fields.versions | find({"name":"5.0.0"}) != null }}

References