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

Mike Rathwell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2015

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
Answer accepted
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2015

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. 

Mike Rathwell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2015

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
TAGS
AUG Leaders

Atlassian Community Events