Versions Compared

Key

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

Abstract

This code snippet filters values from a multi-valued field based on a condition

Logic

Use the "filter" Nunjucks filter to filter the values that meet the condition

Snippet 

Code Block
languagejs
linenumberstrue
{# Filter the values from the multi-valued field using "filter" filter #}
{{ issue.fields['<Multi-valued field name>'] | filter(<Condition>) | join(",","name") }}

...

PlaceholderDescriptionExample
<Multi-valued field name>Name of the multi-valued fieldWatchers
<Condition>Condition to meet for the value to be filtered{name:'rvijji'}

Context

The output of this snippet is a subset of the existing values of a multi-valued field which you could use in a template to:

  • Set a multi-valued field to a subset of the existing values in one of the Set field value post-functions. Example: Set a Multi-user picker type field to the users in the Watchers field who belong to the Europe/Berlin time zone:

    Code Block
    languagejs
    linenumberstrue
    {{ issue.fields['Watchers'] | filter({"timeZone": "Europe/Berlin"}) | join(",","name") }}


  • Send an email to all the users of the Request Participants when a meeting schedule has been changed, except to the current user in the Email issue post-function

    Code Block
    languagejs
    linenumberstrue
    {{ issue.fields['Request Participants'] | filter({name:currentUser.name} , true) | join(',','name') }}


...

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

...