スマート バリューとは
Smart values are dynamic variables that can make your rule more flexible. They can add power and complexity to your automation rules.
スマート バリューをフォーマットする
Each smart value is constructed using a specific syntax called dot notation inside double mustache brackets. It's written as a hierarchy, starting with a top-level object and followed by properties of that object, {{object.property.subProperty}}. This practice of connecting properties, sub-properties, and functions into a single smart value is sometimes called “chaining”.
Notice that multiword properties use camelCase capitalization.
{{issue}}→ top‑level object{{issue.summary}}→ property{{issue.assignee.displayName}}→ sub‑property
特定のスマート値が何をするのかを理解しようとする際は、英語として後ろから読むことで分かりやすくなります。次に例を示します。
{{page.title}} is "the title of the page" (that's relevant to your rule component).
{{page.parent.title}} は「(関連する) ページの親のタイトル」です。
Functions and methods
In addition to chaining sub-properties, smart values can be amended with functions. Functions are operations you’re asking the system to perform on that value. Functions are easy to identify because they are always followed by parentheses ( ). The parentheses may or may not be empty. For example:
{{now.plusDays(5)}} is “add 5 days to the current time”
{{issue.summary.toLowerCase()}} is “lower case the Summary of the work item (issue)”.
Other functions might include substring() or concat().
使用可能なスマート値の見つけ方
The easiest way to find which smart values are available for your rule is to search and select from a list in an automation component. From the rule builder:
「メールを送信」アクションなど、独自のテキストを入力するアクションを選択します。
テキスト フィールドの
{}ボタンを選択すると、互換性のあるスマート値リストが開きます。目的のスマート値が見つかったら、コピー アイコンを選択してテキスト フィールド貼り付けます。
You can also view lists of smart values available for automations in Jira and Confluence.
To see which functions you can use (like toLowerCase() or substring()), open the {} smart values panel in a rule, then look under Advanced formatting.
In Jira Automation, you can investigate the REST API to find available smart values for a work item. See how to find smart values for a Jira Cloud field.
スマート バリューをテストする
この機能は Jira 自動化でのみ利用できます。
スマート バリューが何を返すかテストする方法:
自動化のルールビルダーを開きます。
ルールのトリガーとして [Manual trigger from work item (作業項目の手動トリガー)] を選択します。
ルールのアクションとしてログ アクションを選択します。
作業項目に移動して [ルールを実行] を選び、手動でルールをトリガーします。
The result will be visible in the audit log.
スマート バリューの関数をチェーン化する
スマート関数を連結するだけで、1 つのステップで複数の変換を適用できます。
下の例では、スマート値 toLowerCase、substring、concat を連鎖させて作業項目の要約を小文字に変更し、最初の 10 文字だけを残して、文末に !! を追加します。
{{issue.summary.toLowerCase().substring(0, 10).concat("!!")}}セクションとリストでスマート値を使う
複数のアイテムがあるスマート値を操作する際は、# とスマート値を併用してルールをリストのすべてのアイテムに適用できます。
たとえば、スマート値 {{issue.comments}} を使用してアクセスし、作業項目のコメントを返します。ただし、作業項目にコメントが複数ある場合は、スマート値 {{#issue.comments}} によって各コメントで個別にルールが反復されます。# を使用する際は、式を {{/}} で閉じる必要があります。
たとえば、作業項目のコメント作成者の一覧を出力するには、以下を使用します。
{{#issue.comments}}Author: {{author.displayName}}{{/}}To treat items as numbers, use {{#=}} when using a math function. For example, to add 100 to an Invoice amount custom field:
{{#=}}{{issue.Invoice Amount}} + 100{{/}}デフォルト値
フィールドまたは値が存在しない場合は空の値 ({{invalid reference}}) を返します。これを避けるためにデフォルト値を指定できます。
たとえば、無効な参照に値が含まれていない場合、{{invalid reference|"Hello world"}} を使用して Hello world を表示できます。
スマート値をカスタマイズ
In Jira Automation, you can define your own custom smart values using the Create variable action.
スマート値のヘルプ パネルでは、スマート値、関数、メソッドをカスタマイズすることもできます。[カスタム フィールド] タブには、ルールを実行するスペースやスコープに固有のカスタマイズされた値が表示されます。また、[詳細な書式設定] タブの関数やメソッドに独自のデータを入力して、出力を簡単にカスタマイズすることもできます。
この内容はお役に立ちましたか?