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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

77 views 0 5
Read article

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