How can I use macros from someone else inside my own macro

Hey there,

I want to create a simple macro, where a user has to put in a number, which is afterwards used inside another macro to do a database request.

So now my question is, how can I call a macro within my macro? Or is this even possible?

Kind regards,

Christopher Graß

3 answers

1 accepted

You can use another macro inside your user macro with this:

<ac:macro ac:name="profile">
    <ac:parameter ac:name="user">$content.getCreatorName()</ac:parameter>
</ac:macro>

Naturally you'd be using a different name and different parameter values based on what the macro your including uses.

Within your macro, construct the appropriate wiki markup or xhtml markup and render it using the appropriate renderer.

For a user macro it would be something like this when using wiki markup:

$action.getHelper().renderConfluenceMacro("{noformat}stuff{noformat}")

I m afraid I don't know what you exactly mean by "appropriate renderer".

Do you mean I have have to choose the correct rendering definition when I want to create a macro?

Let's say, I want to use the SQL macro, this is how I started.

## @param PfNummer:title=Nummer|type=string|required=true


{sql:dataSource=myDB} 
select value1,value2
from test_table where pf_value3='$paramPfNummer' 
{sql}

The input variable gets replaced inside the sql string, but obviously the macro does not execute the sql string.
Any idea how I can solve this problem?

Edit: I am currentyl working with Confluence version 4.3

I managed to do it by using the action.getHelper() method, rendering the whole content into xhtml.

Thanks for helping me.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,755 views 11 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot