Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
Column
  1. Design a page with the run macro as normal with a few dummy choices
  2. Create a choices sql select statement that produces a set of rows where each row is a text field of the form: value:choice: - value is the replacement value that is needed and choice is the choice text that the user will see
  3. Setup the sql-query macro on a page to run the choices sql
    • Use table=false
    • Verify the result of the sql-query macro is a colon separated string of values and choice text
  4. Copy the groovy example and replace the run and sql portions with your definitions
    • Note that the $ in front of replacement variables used must be escaped in groovy by the **
Code Block
{groovy:output=wiki}
import com.atlassian.renderer.v2.RenderMode

def renderMode = RenderMode.suppress(RenderMode.F_FIRST_PARA)

def choiceSql = "select distinct(year) || ':' || 'Report ' || year || ':' as choice from reports order by choice desc"

def choiceMacro = "{sql-query:datasource=testDS|table=false} ${choiceSql} {sql-query}"

def choices = subRenderer.render(choiceMacro, context, renderMode)

def runMacro = """
{run:id=dynamic|autorun=true|replace=report:2010::select::${choices}}
{sql-query:datasource=testDS}
select * from reports where year = \$report
{sql-query}
{run}
"""

out.println runMacro
{groovy}
Column

...