スマート バリュー - 数式
Check out how we use smart values in our Jira automation template library.
以下のスマート バリューを使って、ルール設定時に数値を挿入してフォーマットできます。
To use a math expression, you need to use {{#=}}
:
{{#=}}{{issue.Invoice Amount}} * 1.2{{/}}
Numerical operations
You can perform numerical operations on (and between) smart values using the following smart values.
Abs
Returns the absolute value of a number. For example, the absolute value of -6 is 6. This is useful for finding and returning the difference between two custom fields, for example Projected grown and Actual growth.
例:
Projected growth is off by {{issue.Projected growth.minus(issue.Actual growth).abs}}
Round
Returns a number rounded to the nearest whole number. For example, 1.6 is rounded to 2.
例:
{{issue.timetracking.timeSpentSeconds.divide(3600).round}}
Floor
Returns the lower value of a number. For example, 1.9 returns 1.
例:
{{issue.timetracking.timeSpentSeconds.divide(3600).floor}}
Ceil
Returns the upper value of a number. For example, 1.1 returns 2.
例:
{{issue.timetracking.timeSpentSeconds.divide(3600).ceil}}
Plus/Minus
Adds or subtracts one numerical smart value with another. For example, you could update the current story point estimate for an issue by adding a point for each subtask.
{{issue.Story Points.plus(issue.subtasks.size)}}
Multiply
Multiplies one numerical smart value with another. For example, you could set the target date of an issue as + 3 days for each story point.
{{now.plusBusinessDays(issue.Story Points.multiply(3))}}
Divide
Divides one numerical smart value with another. For example, you could find the number of hours per person spent on an issue.
We spent {{issue.timetracking.timeSpentSeconds.divide(3600).divide(issue.Request participants.size)}} hours per person on this ticket
Numerical comparisons
The following smart values are used to compare a numerical smart value with a given number. These values return either true or false, and can be combined with #if to print more helpful text based on the outcome.
指定の値より大きい
- Syntax:
gt(value)
Takes a numerical smart value, and checks if it is greater than the value given. For example, you can check the number of votes an issue has received, and print the words "Popular issue" if it has more than 100 votes.
{{#if(issue.Votes.gt(100))}} Popular issue {{/}}
指定の値以上
- Syntax:
gte(value)
Takes a numerical smart value, and checks if it is greater than the value given. For example, you can check the number of votes an issue has received, and print the words "Popular issue" if it has 100 or more votes.
{{#if(issue.Votes.gte(100))}} Popular issue {{/}}
Equal to
- Syntax:
eq(value)
Takes a numerical smart value, and checks if it is equal to the value given. For example, you can check that only one person is involved in a ticket, and print a message if this is the case.
{{#if(issue.Request Participants.size().eq(1))}} Only one person involved {{/}}
未満
- Syntax:
lt(value)
Takes a numerical smart value, and checks if it is less than the value given. For example, you can check if a multi-value custom field has fewer than 2 options selected.
{{#if(issue.Multi Select custom field.size().lt(2))}} Only one option selected {{/}}
指定の値以下
- Syntax:
lte(value)
Takes a numerical smart value, and checks if it is less than or equal to the value given. For example, you can check if a multi-value custom field has 2 or fewer options selected.
{{#if(issue.Multi Select custom field.size().lte(2))}} Too few options selected {{/}}
Format numerical values
フォーマット
Formats a number in US locale. For example, 123412345 becomes 123,412,345.
{{issue.Invoice Amount.format}}
format(input)
Formats a number in the given locale. Learn more about numeric print outputs at the Java documentation.
{{issue.Invoice Amount.format("###")}}
formatWithLocale(input)
Formats a number in the given locale. Eg, for "fr_FR", 123412345 becomes 123 412 345. For a list of locales, refer to the Java documentation.
{{issue.Invoice Amount.formatWithLocale("fr_FR")}}
asPercentage
Formats a number as a percentage in the US locale. For example, 0.123 became 12%.
{{issue.Story Points.asPercentage}}
asPercentage(locale)
Formats a number as a percentage in the given locale. For a list of locales, refer to the Java documentation.
{{issue.Story Points.asPercentage("fr_FR")}}
asCurrency
Formats a number as a currency in the US locale. For example, 0.123 becomes $0.12.
{{issue.Invoice Amount.asCurrency}}
asCurrency(locale)
Formats a number as a currency in the given locale. For example, for "fr_FR", 0.123 becomes 0,12€. For a list of locales, refer to the Java documentation.
{{issue.Invoice Amount.asCurrency("fr_FR")}}
算術演算子
演算子 | 説明 | 例 | 結果例 |
---|---|---|---|
| 加算演算子/単項プラス |
|
|
| 減算演算子/単項マイナス |
|
|
| 乗算演算子 |
|
|
| 除算演算子 |
|
|
| 剰余演算子 (モジュロ) |
|
|
| べき乗演算 |
|
|
ブール演算子
Boolean operators always result in a value of 1 or 0 (zero). Any non-zero value is treated as a true value. Boolean not is implemented by a function.
演算子 | 説明 | 例 | 結果例 |
---|---|---|---|
| 指定の値に等しい |
|
|
| 指定の値に等しい |
|
|
| 指定の値に等しくない |
|
|
| 指定の値に等しくない |
|
|
| 未満 |
|
|
| 指定の値以下 |
|
|
| 指定の値より大きい |
|
|
| 指定の値以上 |
|
|
| ブール演算子 AND |
|
|
| ブール演算子 OR |
|
|
関数
関数では大文字と小文字は区別されません。
機能 | 説明 |
---|---|
NOT(式) | Boolean negation, 1 (means true) if the expression is not zero. |
IF(condition,value_if_true,value_if_false) | Returns one value if the condition evaluates to true or the other if it evaluates to false. |
RANDOM() | Produces a random number between 0 and 1. |
MIN(e1,e2, ...) | Returns the smallest of the given expressions. |
MAX(e1,e2, ...) | Returns the biggest of the given expressions. |
ABS(式) | Returns the absolute (non-negative) value of the expression. |
ROUND(expression,precision) | Rounds a value to a certain number of digits, uses the current rounding mode; helpful with formatting numbers. |
FLOOR(式) | Rounds the value down to the nearest integer. |
CEILING(式) | Rounds the value up to the nearest integer. |
LOG(式) | Returns the natural logarithm (base e) of an expression. |
LOG10(式) | Returns the common logarithm (base 10) of an expression. |
SQRT(式) | Returns the square root of an expression. |
SIN(式) | Returns the trigonometric sine of an angle (in degrees). |
COS(式) | Returns the trigonometric cosine of an angle (in degrees). |
TAN(式) | Returns the trigonometric tangents of an angle (in degrees). |
ASIN(式) | Returns the angle of asin (in degrees). |
ACOS(式) | Returns the angle of acos (in degrees). |
ATAN(式) | Returns the angle of atan (in degrees). |
SINH(式) | Returns the hyperbolic sine of a value. |
COSH(式) | Returns the hyperbolic cosine of a value. |
TANH(式) | Returns the hyperbolic tangents of a value. |
RAD(式) | Converts an angle measured in degrees to an approximately equivalent angle measured in radians. |
DEG(expression) | Converts an angle measured in radians to an approximately equivalent angle measured in degrees. |
定数
定数 | 説明 |
---|---|
E | The value of e, exact to 70 digits. |
PI | The value of PI, exact to 100 digits. |
TRUE | The value one. |
False | The value zero. |
NULL | The null value. |