Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Writing a user macro similar to Task report Macro

Hi people,

I am quite new to writing User Macros in Confluence.

I want to write a user macro with almost the same functionality as the standard 'Task report' macro with the only difference that only the page should be pre-defined to the current page if the Space(s) and Page(s) is left blank. 

Curious to know if anybody had already tried writing and replicating the Task Report macro?

Any support would be gladly appreciated.

Thanks in advance

1 answer

0 votes
Dominic Lagger Community Leader Oct 14, 2021

Hi @t0mhAn3110 

This should be very easy.

Every confluence page has it's own "storage format". There you find xml-based code unrendred.

So the task report will shown as followed:

<p><ac:structured-macro ac:name="tasks-report-macro" ac:schema-version="1" ac:macro-id="32f7ec75-450b-4db7-beb2-f5516e5a0ae9"><ac:parameter ac:name="pages">146866177</ac:parameter></ac:structured-macro></p>

There you just have to replace the pages parameter with the actual pageid.

Full macro here:

## 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

<p><ac:structured-macro ac:name="tasks-report-macro" ac:schema-version="1" ac:macro-id="32f7ec75-450b-4db7-beb2-f5516e5a0ae9"><ac:parameter ac:name="pages">$content.getId()</ac:parameter></ac:structured-macro></p>


Hope this helps.

Regards, Dominic

Bill Bailey Community Leader Oct 15, 2021

I think the poster is looking to not just wrap an instance of the macro, but make java calls to retrieve the data and reformat as needed.

Hi @Dominic Lagger ,

Thank you for the response :)

I tried this:

## Developed by: 
## Date created:
## @param space:title=Space|type=spacekey
## @param user:title=Username|type=username|desc=Select username to display
## @param page:title=Page|type=confluence-content|required=true|desc=Select a page to use

#set( $spaceKey = $paramspace)
#set ( $pageId= $
#set ( $pageId= $pageManager.getPage($spaceKey ,$parampage).getContentId().toLong() )
#set ( $pageTitle= $pageManager.getPage($spaceKey ,$parampage)
#set ($userKey = $userAccessor.getUserByName($paramuser).getKey())
<ac:structured-macro ac:name="tasks-report-macro" ac:schema-version="1" ac:macro-id="32f7ec75-450b-4db7-beb2-f5516e5a0ae9">
<ac:parameter ac:name="pages">$pageId</ac:parameter>

But unfortunately does not seem to work.  

Moreover, I am also trying that if the Space(s) and Page(s) is left blank, the page should be pre-defined to the current page.

Dominic Lagger Community Leader Oct 18, 2021

Why do you use all these variables like "userKey, pageTitle", and so on?

instead of "$pageid" use the


 as I did.

Becuase I need these params.

Anyways, is there anyway to pre-defined to the current page if the Space(s) and Page(s) is left blank?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,632 views 7 30
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you