Expr Language - Variables
Variables are user-defined names, which represent attributes, such as:
Jira issue fields
Calculated attributes like Progress
Structure-specific attributes like Item type
Attributes provided by other Jira apps
Another formula
Values from another Structure column
Naming Variables
Variables can contain letters (English only), numbers or underscore ("_") characters. Variables cannot contain spaces, and the first character must be a letter or an underscore.
Examples:
priority
sprintName
remaining_estimate
abc11
As you write your formula, Structure attempts to map your variables to well-known attributes.For example, the "remaining_estimate" variable above will automatically be mapped to the Remaining Estimate field. See Mapping Variables for more information.
Variable names are case-insensitive. Priority
, priority
and pRiOrItY
will all refer to the same variable.
Local Variables
Local variables are helpful when an expression needs to be used in the same formula several times. For example:
IF time_spent + remaining_estimate > 0 :
time_spent / (time_spent + remaining_estimate)
You can see that in this formula we are using "time_spent + remaining_estimate"
twice – once when we check that it's not zero (so we don't divide by zero) and again when we divide by it.
Instead of repeating the expression every time, we can rewrite this formula using the WITH
construct:
WITH total_time = time_spent + remaining_estimate :
IF total_time > 0 :
time_spent / total_time
You can define multiple local variables in succession. You can also use previously defined local variables when defining additional local variables. For example:
WITH total_time = time_spent + remaining_estimate :
WITH progress = (IF total_time > 0 : time_spent / total_time) :
IF(progress > 0.5, "Great Progress!", progress > 0.2, "Good Progress", "Needs Progress!")
Note the position of the colon (":"
) – it must be present where each local variable definition ends.