Use case

You have a table with page titles. You need to get a dynamic result table where rows correspond to the current page title.

Solution

  1. Switch the page to the edit mode.
  2. Insert the Table Transformer macro and paste the table or the macros outputting tables within the macro body.
  3. Select the macro and click Edit.
  4. In the Presets tab select Custom transformation and click Next.
  5. Enter the following SQL query:

    SELECT *
    FROM T1 
    WHERE T1.'Page Title' = @PAGETITLE
    SQL
  6. Save the macro and the page.


The @pageTitle variable can be combined with other variables within the same query and successfully used in more complex SQL queries.

Use case with several variables

You have a table with the list of people (user names) responsible for publishing documentation pages.

You need to do the following:

  • Find the logged in (current) Confluence user in the 'Responsible' column and color it in blue (the others will be green)
  • Add the current page title (i.e. where the current Confluence user is now) to all the existing page names in the 'Page' table column

Solution

  1. Switch the page to the edit mode.
  2. Insert the Table Transformer macro and paste the table or the macros outputting tables within the macro body.
  3. Select the macro and click Edit.
  4. In the Presets tab select Custom transformation and click Next.
  5. Enter the following SQL query:

    SELECT
    FORMATWIKI("{color:" + IF(T1.'Responsible'= @CURRENTUSER, "green", "blue") +"}" + T1.'Responsible' + "{color}") AS 'Responsible', 
    "@pageTitle - " + T1.'Page' AS '@pageTitle'
    FROM T1
    SQL
  6. Save the macro and the page.

To learn more about the @currentUser variable, please visit the corresponding page.