Making a one to many reference between pages using scaffolding and reporting
Asked by Rene Schade:

Hi,

I'm using the Scaffolding and Reporting plugins to build what is basically a one-to-many relation between two page templates. I just need to get the last piece of the puzzle and need help from the community with this.

I have two page templates both using the scaffolding data item (using the scaffolding live template).

The first page template is a Person and has scaffolding data like name, email, phone number. The template is also labelled 'person'.

The second page template is a car. A car has scaffolding data like brand, color and a reference to the owner: Person. The reference is handled in a "Content Options" macro, were you can chose among pages labelled 'person'. A car page is also labelled 'car'.

What I'm doing is basically a one-to-many relation.

Example:

I can create two pages with the Person template: Brian and Pete.

I can create three pages Ford, Nissan and Volvo.

Ford and Nissan both have a reference to Brian. Volvo has a reference to Pete.

Now to my problem:

On the page Brian I would like to list all the cars he is the owner of.

That is create a Report that searches to pages labelled 'car' and list the one referencing Brian.

But I cannot find a search term maching this in the Reporting macro.

Any suggestions to solutions or alternative solutions are welcome!


Answers:
author: Sayed Bares [ServiceRocket]
body: Hi Rene,

I hope you are having a great day.

The use case you are looking for is totally doable with content reporter macro and here is the reporting structure which you will need to add in Person template to get cars which are owned by each person:

**Reporting structure**

![Reporting Structure.png](https://community.atlassian.com/t5/image/serverpage/image-id/114717i9BF0303D3B5A7A56/image-dimensions/581x284?v=v2 "Reporting Structure.png")

**Text filter settings used within Content reporter macro**

![text filter 2.png](https://community.atlassian.com/t5/image/serverpage/image-id/114715i6B0E623FB9FEA95C/image-dimensions/546x327?v=v2 "text filter 2.png")

***Note:** please make sure to change ++data:Person++ to ++data:name of list data macro which contains content-option macro in car template++*

**End Result:**

![Cars.png](https://community.atlassian.com/t5/image/serverpage/image-id/114716iCA7EB36C8270B97F/image-dimensions/529x164?v=v2 "Cars.png")

To make it easier you can [import](https://community.atlassian.com/t5/Confluence-discussions/How-to-import-storage-format/td-p/970905) the following storage format in the person template:

```
<table class="wrapped">
<colgroup>
<col/>
<col/>
</colgroup>
<tbody>
<tr>
<th>
<span style="color: rgb(23,43,77);">Name</span>
</th>
<td>
<div class="content-wrapper">
<ac:structured-macro ac:macro-id="292be8f2-4607-439e-8e03-02761894f2a7" ac:name="text-data" ac:schema-version="1">
<ac:parameter ac:name="name">Name</ac:parameter>
<ac:parameter ac:name="type">line</ac:parameter>
<ac:parameter ac:name="content">text</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</div>
</td>
</tr>
<tr>
<th>
<span style="color: rgb(23,43,77);">Email</span>
</th>
<td>
<div class="content-wrapper">
<ac:structured-macro ac:macro-id="b3377536-ca99-448d-abc6-4a6b702941ce" ac:name="text-data" ac:schema-version="1">
<ac:parameter ac:name="name">Email</ac:parameter>
<ac:parameter ac:name="type">line</ac:parameter>
<ac:parameter ac:name="content">text</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</div>
</td>
</tr>
<tr>
<th>
<span style="color: rgb(23,43,77);">Phone number</span>
</th>
<td>
<div class="content-wrapper">
<ac:structured-macro ac:macro-id="11c7ff86-ccf5-4557-9639-d60b9275a2c5" ac:name="number-data" ac:schema-version="1">
<ac:parameter ac:name="name">Phone</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
</ac:structured-macro>
</div>
</td>
</tr>
</tbody>
</table>
<p>
<br/>
</p>
<p>
<br/>
</p>
<hr/>
<p>
<br/>
</p>
<p>All cars owned by?<ac:structured-macro ac:macro-id="79e33dd7-0c66-46d3-b85a-e802c9c39265" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">page:title</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="7187b080-c6c0-498a-99c4-9696cdc460e3" ac:name="report-block" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="cfb42d39-f273-4cf3-ab1d-780913674f10" ac:name="content-reporter" ac:schema-version="1">
<ac:parameter ac:name="labels">car</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="f2ae1804-8882-422a-8c16-acb1c5e6770e" ac:name="text-filter" ac:schema-version="1">
<ac:parameter ac:name="contains">%page:title%</ac:parameter>
<ac:parameter ac:name="">data:Person</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="d123be62-b661-44b5-a933-753fabeec474" ac:name="report-body" ac:schema-version="1">
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="f8dae426-1c7f-45a9-949a-f14d42e43b89" ac:name="panel" ac:schema-version="1">
<ac:parameter ac:name="bgColor">lightblue</ac:parameter>
<ac:rich-text-body>
<ul>
<li>
<ac:structured-macro ac:macro-id="05037831-681b-4753-b250-369360ddb3d6" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">page:title</ac:parameter>
</ac:structured-macro>
</li>
</ul>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>
<br/>
</p>
```

Hope it helps and if you require further assistance then feel free to reach out to ServiceRocket support through [here](http://support.servicerocket.com/).

Best,

Sayed


Tags: confluence-server

report

scaffolding

server

servicerocket