Formula field (number) and examples

The field has two options for working with the value. Both options are regulated by the connected search engines in the field settings.

  • value as a number

  • value as time

value as a number

Number searcher - Enables the standard indexing and jql algorithm with numeric fields.

 

value as time - JQL functions for search by Time

Several jql functions are available for the "Formula (number)" field.
The first thing you need to enable indexing for a field. To do this, specify the Search Template: "Time searcher" field in the settings. It is enabled by default.
After changing the settings, you need to run reindex Jira.

JQL functions take the following parameters.

  • condition - one of the characters <, <=, => =,>. For example: ">".

  • time - time string corresponding to one of the patterns.

"5h35m12s" - 5 hours 35 minutes 12 seconds "5h12s" - 5 hours 12 seconds 3000m - 3000 minutes "0", "0s" ... - time is zero.


Functions available for the field are called via the "in" operator.

  • "Formula (number)" in time_cf("condition","time") - returns tasks for which the time between dates is greater than, equal to, or less than the specified (condition).

  • "Formula (number)" in timeBetween_cf("time","time") - Returns tasks that have the time in the specified range.

Examples

  • "Formula (number)" in time_cf (">", "1h")

  • "Formula (number)" in time_cf ("<", "1h 12m)

  • "Formula (number)" in timeBetween_cf("1h", "2h")

     

Field "Formula(number)" examples

Field for calculating the sum of two other numeric fields. The other fields have the id 10000 and 10001.

Formula (JavaScript): return number

cfValues[10000] + cfValues[10001]

If one of the fields(10000) does not have a value, cfValues[10000] returns null, which will be taken into account in the formula according to JavaScript logic: https://stackoverflow.com/questions/21001320/is-null-considered-zero-and-undefined-not-a-number-on-arithmetic-expressions

For additional processing of the null value, you can use cfValues.getOrDefault(10001, deafultValue). in this case it returns 0 as the default value:

cfValues.getOrDefault(10001, 0)

 

Run demo on issue TEST-1.

In the Formula Result section, we got the value of this formula. This value will be indexed and searchable.

Result View value: How the field value will be displayed in the issue.

 

Prepare value for view (JavaScript): return string. Can return an html string.

A script that does not affect the value. It allows you to further process the value for displaying it in the issue. For example, you can take values from other fields to compare with the value of this field and show the result of this comparison. If empty then the task will be displayed in View (HTML) or Formula Result.

View (HTML)

Another additional step that allows you to add html markup to the value of your field. For example units of measurement.

 

if $formulaValue and $prepareFormulaValue are null then they will be displayed as "$formulaValue" and "$prepareFormulaValue".