Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
Fetch a subset of values of a multi-valued field based on a condition
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
{# Filter the values from the multi-valued field using "filter" filter #} {{ issue.fields['<Multi-valued field name>'] | filter(<Condition>) | join(",","name") }}
Placeholders
Placeholder | Description | Example |
---|---|---|
> | Name of the multi-valued field | Watchers |
> | Condition to meet for the value to be filtered | {accountId: 'accountId:5ca5b1469a000c1180956957' } |
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:
{{ issue.fields['Watchers'] | filter({"timeZone": "Europe/Berlin"}) | join(",","accountId") }}
Send an email to all the customers watching the ticket using the Email issue post-function. For this, you need to add this script in the "Users from script" field in the post-function configuration
{{ issue.fields['Watchers'] | filter({"accountType": "customer"}) | join(",","accountId") }}
References
- How to insert information using Nunjucks annotations
- Accessing fields of an issue
- Custom filter - filter
Related articles
Filter by label
There are no items with the selected labels at this time.