Report Variable

Description

Defines a temporary variable that can hold data in the current report context.

If used outside a report the value will only last for the current page request. Variables can be overwritten further down the page content, but are each unique to a particular report context. Use in conjunction with the Variable Supplier to retrieve variables for use.

Parameters

Name

Required

Migratable to Cloud?

Default Value

Description

Name

Required

Migratable to Cloud?

Default Value

Description

Name

 

  • (/)

 

 

  • NO

 

 

The name for the variable. Any existing variable in the same context with the same name will be replaced.

Value

 

  • (X)

 

 

  • NO

 

 

Either value or a reporter in the macro body must be specified.

This can be a text value or an %injected% value. If the latter, and the whole value is a single %injection%, the actual value will be stored. If it is a mix of text and injections it will be a text value.

Default Value

 

  • (X)

 

 

  • NO

 

 

Either a text value or an %injected% value. This will be used if the value/reporter is empty.

Editor View

  • Not applicable.

Macro Edit View

  • Not applicable.

Notes

The body can also be used to store a "reporter", such as Local Reporter or Content Reporter. The report results will be cached and can be reused multiple times on the same page. For example, the following will store the list of pages with the "foo" label in descending order as "foo":

{report-variable:foo} {content-reporter:type=page|label=foo} {text-sort:page:title|order=descending} {content-reporter}{report-variable}

It can then be executed in a report by using Local Reporter:

{report-list} {local-reporter:variable:foo} {report-body}{report-info:page:title|link=true}{report-body} {report-list}

The same "variable:foo" could be used in other reports on the page, and even have additional "sort" or "filter" macros applied.

It can also be used directly in a Report On or Report Info macro and the results iterated over.

Quick Examples

Setting variables to specific values

In conjunction with the Value Supplier, you can set a variable to a specific text, number, or even Confluence content value:

{report-variable:a number|value=%value:number 12345%} {report-variable:a date|value=%value:date(dd-MMM-yyyy) 25-Nov-2009%} {report-variable:a page|value=%value:content SPACE:My Page%}

Looping variables

You can set variables up to increment through a report loop.

Store a selected random value in the report output

You can use a report variable to store a selected random value in the report output. In this example, for each page label on the current page, we are storing random content with the same label and extracting additional data from that randomly selected page.

Reusing Reporter configurations

The Query Supplier was added in Reporting 3.3.0. Ensure you have upgraded to use this example.

You can store a reporter query as a variable, either to use via Report Info or to execute in a separate report via Local Reporter.

Random Foo:

All Foo Children:

Tutorial Examples

Â