How do I pass metadata value to Bob Swift SQL macro as variable value

Using the Confluence macro metadata 2, I would like to set a handful of pieces of metadata for a page (project number, JIRA key for example) and have those passed to variables in (Bob Swift) SQL queries

In my trial I set a hidden metadata value with the key "projectcode", In wiki markup:

{metadata:projectcode|hidden=true}[A1234]{metadata}

and using metadata-from as follows:

{metadata-from:projectcode}

I return "A1234"

In my sql statement

    select actual from gates where project_code = 'A1234' and gate = 'S4'

which is contained within the SQL macro I would like to replace (in some way) the currently hardcoded 'A1234' with the SOME variable that is populated by the metadata contained within projectcode. 

This will allow me to parameterize the pages we use in this fashion as a template; add a few pieces of metadata to the page and presto it works for whatever project I am pointing it at.

1 answer

1 accepted

0 votes
Accepted answer

One way would be use the Run macro (or Run-now macro) around the SQL macro and the meta-data substitution capability. The reporting macros can do the same kind of thing if you have that. 

Thanks Bob. That works great and you actually ended up also answering a question I was GOING to have. While you answered that one in that way I continued to RTFM and realized that I needed to check the "Evaluate wiki markup" option in the macro and then the statement select actual from gates where project_code = '{metadata-from:projectcode}' also worked. Thanks for your speedy response.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

991 views 14 12
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