Jira スマート バリュー - リスト
Some fields contain more than one option, such as checkboxes, labels, multi-selects, and multi-user pickers. You can use smart values to access these fields using several convenient methods we've added for working with lists.
On this page:
Let's explore a few use cases. Suppose you have a multi-checkbox field called 'Sydney Attractions' with three options:
- Harbour Bridge
- オペラ ハウス
- ボンダイ ビーチ
There are several ways to render this list of values:
List type | Smart value example | 出力 |
---|---|---|
Comma-separated list | {{issue.Sydney Attractions.value}} | Harbour Bridge, Opera House, Bondi Beach |
Dash-separated list | {{#issue.Sydney attractions}} {{value}}{{^last}}- {{/}}{{/}} | Harbour Bridge - Opera House - Bondi Beach |
Space-separated list | {{#issue.Sydney attractions}}{{value}} {{/}} | Harbour Bridge Opera House Bondi Beach |
Using join method | {{issue.Sydney attractions.value.join(" ")}} | Harbour Bridge Opera House Bondi Beach |
These types of fields use .value
to access the human-readable label. You can also access .id
. Applicable fields include:
- リストの選択
- 複数選択リスト
- カスケード選択リスト
- ラジオ ボタン
- Multi-checkboxes
- 複数ユーザー選択機能
Multi-user pickers function similarly to other multi-fields, but you have full access to all of the user's attributes, such as .displayName
. For example, if you have an "Aussie actors" multi-user picker with:
- Hugh Jackman
- Nicole Kidman
- Eric Bana
You can use these smart values to access this picker:
操作 | Smart value example | 出力 |
---|---|---|
Display names | {{issue.Aussie actors.displayName}} | Hugh Jackman, Nicole Kidman, Eric Bana |
Display names with email addresses | {{#issue.Aussie actors}}{{displayName}} ({{emailAddress}}) {{/}} | Hugh Jackman (hugh@wolf.com) Nicole Kidman (kid@nicole.com) Eric Bana (wog@aussie.com) |
Lists smart values
The following smart values are available to access and format the value of items in a list when setting up a rule:
- list
- list.join(separator)
- list.get(index)
- list.getFromEnd(index)
- list.first
- list.last
- list.size
- list.average
- list.max
- list.min
- list.sum
list
リストを順に処理して表示します。また、他のメソッドやプロパティを参照できます。
{{issue.fixVersions.name}}
list.join(separator)
リストを順に処理して、所定の文字で区切られた項目を出力します。次のスマート バリューは修正バージョンの名前を表示して「-」で結合します。
{{issue.fixVersions.name.join(" - ")}}
リストを順に処理して表示します。また、複数の他のメソッドやプロパティを参照できます。
{{#issue.fixVersions}}{{name}} {{releaseDate}}, {{/}}
ラベルのリストを順に処理して、それを表示します (.
は反復対象の現在の項目を参照するためのショートカット)。
{{#issue.labels}}{{.}}, {{/}}
list.get(index)
指定したインデックスにある要素。0 は配列の最初の要素を指します。
{{issue.comments.get(1).body}}
list.getFromEnd(index)
末尾から指定したインデックスにある要素。0 は配列の最後の要素を指します。
{{issue.comments.getFromEnd(1).body}}
list.first
リストの最初の項目です。以下の例は最初のコメントの本文です。
{{issue.comments.first.body}}
list.last
リストの最後の要素
{{issue.comments.last.author}}
list.size
リストのサイズ
list.average
一覧のすべての数の平均を求めます。
{{issue.subtasks.Story Points.average}}
list.max
一覧の最も大きな数または最新の日付を検索します。
{{issue.subtasks.Due date.max}}
list.min
一覧の最も小さな数、または一番早い日付を検索します。
{{issue.fixVersions.releaseDate.min}}
list.sum
一覧のすべての値の合計を求めます。
{{issue.subtasks.Story Points.sum}}
例
リストを順に処理して、最初の要素に「first」ブロックのみを入力します。また、要素に「first」と呼ばれるメソッドまたはプロパティがある場合は「_first」を使用できます。
{{issue.comments.size}} {{#list}}{{#first}}..{{/}}{{/}}
コメント本文全体を出力して、最初のコメントの前に「First:」を配置します。
{{#issue.comments}}{{#first}}First:{{author.key}}{{/}}{{body}}{{/}}
リストを順に処理して、最後の要素に「last」ブロックのみを入力します。また、要素に「last」と呼ばれるメソッドまたはプロパティがある場合は「_last」を使用できます。
{{#list}}{{#last}}..{{/}}{{/}}
コメント本文全体を表示し、最後のコメントの前に 「Last:」を配置します。
{{#issue.comments}}{{#last}}Last: {{/}}{{body}}{{/}}
リストを順に処理して、最初の要素を除く各要素に「first」ブロックを入力します。また、要素に「first」と呼ばれるメソッドまたはプロパティがある場合は「_first」を使用できます。
{{#list}}{{^first}}..{{/}}{{/}}
すべてのコメント本文を表示して、最初のコメントを除くすべてのコメントの前に「Not First:」を配置します。
{{#issue.comments}}{{^first}}Not First:{{author.key}}{{/}}{{body}}{{/}}
リストを順に処理して、最後の要素を除く各要素に「last」ブロックを入力します。また、要素に「last」と呼ばれるメソッドまたはプロパティがある場合は「_last」を使用できます。
{{#list}}{{^last}}..{{/}}{{/}}
コメント本文全体を出力して、最後のコメントを除く各コメントの後にカンマを配置します。
{{#issue.comments}}{{body}}{{^last}},{{/}}{{/}}
現在のアイテムのインデックスを表示します。また、要素にメソッドまたは index というプロパティがある場合は _index も利用できます。
{{#list}}{{index}}{{/}}
上記と同様ですが、前のコメントのインデックスを表示します。
{{#issue.comments}}{{index}}. {{body}}{{^last}},{{/}}{{/}}
すべてのラベルに「option-」という接頭語を付けて出力して、最後のラベル以外すべてのラベルの後ろにカンマを配置します。
{{#issue.labels}}option-{{.}}{{^last}},{{/}}{{/}}