How to create a page properties macro from user macro?

Suresh Sakhare
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 28, 2018

Hi,

I want to create user macro which create the page properties macro with all property value and custom body.

I have inserted page property macro storage format code in user macro.So when I insert user macro on page automaticaly page property macro will be create with all data.

## Macro title: My Macro
## Macro has a body: Y or N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: My Name
## Date created: dd/mm/yyyy
## Installed by: My Name

## This is an example macro
## @noparams
<ac:structured-macro ac:name="details" ac:schema-version="1" ac:macro-id="f52950d2-6006-4cdc-a53b-a680eeaf5934"><ac:parameter ac:name="hidden">false</ac:parameter><ac:parameter ac:name="id">1</ac:parameter><ac:rich-text-body>
<table class="relative-table wrapped" style="width: 34.0856%;"><colgroup><col style="width: 14.1156%;" /><col style="width: 24.6599%;" /><col style="width: 17.3469%;" /><col style="width: 19.5578%;" /><col style="width: 14.4558%;" /><col style="width: 4.93197%;" /></colgroup>
<tbody>
<tr>
<th>Author</th>
<th>Email</th>
<th>Designation</th>
<th>Cell</th>
<th colspan="1">Location</th>
<th colspan="1">Area</th></tr>
<tr>
<td>Suresh Sakhare</td>
<td><a href="mailto:suresh.sakhare@example.com">suresh.sakhare@example.com</a></td>
<td>Software Engineer, XXX Team</td>
<td>+09970037010, +09970037010</td>
<td colspan="1">Pune, Maharashtra, India</td>
<td colspan="1">APAC Region</td></tr></tbody></table></ac:rich-text-body></ac:structured-macro>

 Thanks in advance.

4 answers

3 votes
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2018

I will tell you from personal experience, you can make what looks like a page properties macro on the page, BUT the page properties report macro will NOT read the data.

0 votes
Michael Rosenberger
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 10, 2019

I currently have the same problem. Is there still no way of using the page properties macro in a user macro?

0 votes
Jorge October 30, 2018

Got the same experience as Bill, does not work. The possible reason is that the page properties are parsed out of the html of the page. Because the table is now not part of the html anymore (wrapped into the macro), the read page property function will not find your properties.
Sad, I also thought I could wrap my property table in a nice user macro. 
I would be happy if I can be proofed wrong here :-) or somebody has an idea to bring it to work.

Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2018

Me too. I spent a fair amount of time writing a user macros with settings, only to have to break it up in to a number of smaller macros.

My guess is the same as yours: that the report macro is looking at the storage view of the page, and not the rendered version of the page. So while you can make something that renders the same, the storage view is different.

Like Michael Rosenberger likes this
0 votes
JP _AC Bielefeld Leader_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2018

Hi Suresh,

the Page Property macro expects the information displayed in a report in rows, not columns. From just checking your code, I see that you use columns for the data, not rows.

Create a Page Property macro on a page, insert a table with different rows Author, Email, Designation,,, and the data in a second column. Use the "Source Editor":

https://marketplace.atlassian.com/apps/1210722/confluence-source-editor?hosting=server&tab=overview

to get an idea of the Confluence storage format for the macro & embed the code into your user macro.

And don't forget to tag the page with a label...

Best

JP

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events