Retrieving stored data from inside a table

Data stored in table fields created with the Table Data macro can be accessed and displayed with the Get Data macro.

In this example, we will create a simple table that stores the names of staff members who are currently involved in a project and also what roles they hold in that project.

And then we will use two Get Data macros to retrieve data from the table so that we can form a sentence that says:

"This project has <STAFF NAME> and their role is <STAFF ROLE>."

Ingredients

Apps
Scaffolding
Platform
Server, Data Center
Macros
Suppliers

Guide

  1. Start by creating a Table Data macro.
    Set the Name parameter to "table".



  2. Within the Table Data macro, create a table using the Editor tools like this:



  3. Inside the empty cell under the "Name" column, create a Text Data macro.
    Set the Field Name parameter to "tableName".
    Change the Type parameter to line.
    Change the Content Type parameter to text.



  4. Inside the empty cell under the "Role" column, create a Text Data macro.
    Set the Field Name parameter to "tableRole".
    Change the Type parameter to line.
    Change the Content Type parameter to text.



  5. You should have a Table Data macro that now looks like this:



  6. Now save the page, and click the Edit Contents button so that we can start populating the table we just created with names and roles.
    This is an example of what we came up with:



    Once you are done, click Save.

  7. Now that we have a table with data, we can use the Get Data macro to retrieve the data and build a sentence using the names and roles from the table.

  8. Write the following phrase in the editor under the Table Data macro:
    "This project has"

  9. Immediately after that phrase, create a Get Data macro.
    Set the Field Name parameter to "table.0.tableName".
    This means we are calling the "tableName" field name from the first row ("0") in the Table Data macro named "table".



  10. Immediately after that Get Data macro, type in the following phrase:
    "and their role is"

  11. Immediately after that phrase, create a Get Data macro.
    Set the Field Name parameter to "table.0.tableRole".
    This means we are calling the "tableRole" field name from the first row ("0") in the Table Data macro named "table".



  12. You should now have a collection of two Get Data macros that look like this in your Confluence editor:



  13. Save the page and check the results.


Notes

The first row has a number of 0.

For example, table.0.text accesses the first row of table.text.


Result