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
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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= $content.id)
#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>
</ac:structured-macro>
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why do you use all these variables like "userKey, pageTitle", and so on?
instead of "$pageid" use the
$content.getId()
as I did.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.