Availability

Child pages
  • Run macro

Skip to end of metadata
Go to start of metadata

On this page

Description

Provides a user form with input fields before rendering the body of the macro. Form fields will be used to replace variables in the body prior to rendering. Field values can be provided by user interaction, pre-defined variables, or request parameters. Any text in the macro body that begins with $ immediately followed by a key found in the replace parameter list (see Field types for details) will be replaced by the value. Normally, values will be provided by a user submitting a form from the page based on the replace parameter. Default values can be specified.

This macro may have restricted use for security reasons. See Macro Security for Confluence and consult with your administrator for details.

Variables

Migration warning

If you continue to use legacy wiki markup, you must assign a unique id (see the id parameter) if there are more than one run macros on the same page. In this case, the default id generated in wiki mode is always 1 which only works correctly if only 1 run macro is on the page. Either convert the macros to rich text or add unique ids.

Parameters

Field Types

See Field types.

Advanced capabilities

Examples

Release notes 2.0 shows some examples of advanced capabilities.

Examples:

  1. Horizontal radio button - gender:M:Gender:radio::M:Male:F:Female
  2. Single select with 12 lines - month:12:Month:select:12:1:Jan:2:Feb:3:Mar:4:Apr:5:May:6:Jun:7:July:8:Aug:9:Sept:10:Oct:11:Nov:12:Dec
  3. Checkbox (value same as text) - day::Day of$nbsp;week:checkbox-required:7:Sunday::Monday::Tuesday::Wednesday::Thursday::Friday::Saturday

Export

The html, representing the rendered body of the macro, can be exported to a page attachment or to the file system. This enables the dynamic content to be captured at a point in time for later viewing. An attachment or file created by this type of export, can be used on a page by including it in the body of an html macro. For example: {html:script=^bobs.html} {html}. If exportVersion=keep is used, the referenced attachment is already there, and the HTML macro is authorized for use on the page, then the macro body will not be rendered and the attachment will be included instead. This enables caching and automation capabilities.

Recursive use

When using wiki markup, identical macros run, run1, and run2 are provided to enable recursive use of the macro.

Request parameters

Request parameters are case sensitive. Look at the url after pressing the run button or after an autorun. This url can be used as a link. Usually the url contains the page title. If the page title contains special characters or you wish to have a more persistent link (that survives page renames or moves), then Confluence's alternate page view url can be used: .../pages/viewpage.action?pageId=......... The view url can be constructed by looking at the url after going to Tools->Info. Tiny links cannot be used (CONF-11594   ). Each parameter is represented by a request parameter composed of _ separated elements:

  • run - constant
  • id - id associated with this run instance - see the id parameter
  • parameter key - first component of the key:value:description triple

An example is: run_1_gender=M. An example of the run action is: run_1=run, this causes the action to run. Exclude this from the link if you just want the parameters filled in, but want the user to press the button.

The group pseudo field type does not result in a requestParameter. The request parameter representation can be controlled using the requestPrefix and requestAction parameters.

Fields that allow multiple selections

Checkbox and multi-select fields allow multiple selections and are more complex. Special considerations are:

  • If the initial value needs to be specified with more than one selection, the value must be a single quoted, comma separated list of choice values.
  • The replacement value for such a field is a single quoted, comma separated list of single quoted selected values.
  • Checkbox and multi-select entries appear multiple times as request parameter with value matching values that have been selected.
  • Embedded single quotes are doubled.

Translation

Text visible to form users (field titles, parameter descriptions, and choice text) can be provided so that it is translatable by using @ followed by a key to the translatable resource. This means that the form will show text specific to the user language setting.

  • Any valid i18n key defined in Confluence can be used (example: @dashboard.name)
  • Custom keys (beta - subject to change based on user feedback)
    • Can be defined and accessed via @custom.example.key.
    • This requires customization that requires your system administrator. Custom keys must be added to a property file named org.swift.confluence.run.custom.properties. Appropriate language translations property files named after the language abbreviation (example: org.swift.confluence.run.custom_fr.properties) and inserted into the add-on jar under i18n directory.

Usage

The following examples are given in wiki markup format so it is easy to copy and paste. Use Insert ->Markup in your Confluence editor to paste in the examples.

Run example

Run a script

{run:replace=greeting:Hello,who:Bob}
{beanshell}
System.out.println("$greeting $who");
{beanshell}
{run}

Run a SQL query

{run:replace=first:Bob:First name|exportFile=^bobs.html|titleExport=Archive result}
{sql:datasource=NameDS}
select * from NAMES where first='$first'
{sql}
{run}
  • No labels

93 Comments

  1. Working with date.

    I'm trying to use a date field but with $current_date it ain't working

    after:$current_time:from date (gg/mm/aaaa):date-required:01/01/1994:31/12/2020:dd/MM/yyyy

    The result is a misplaced filed value and description.

    Another question

    Is it possible to set as date default "3 month ago" or something similar?

    thanks

      1. Date field
        • A value containing colon or comma must be quoted - '$current_time'. Since you didn't provide the dateFormat parameter, your current time contained a : for instance.
        • Since you want a specific date format, try this instead - note the date format of the field defaults to the dateFormat parameter, so it does not need to be provided in this case
          {run:replace=after:$current_time:from date (gg/mm/aaaa):date-required:01/01/1994:31/12/2020|dateFormat=dd/MM/yyyy }
          
      2. 3 months ago? - no, you would need to do something more complicated to achieve this like a script or sql or perhaps metadata.
  2. I'm trying to use a comma for values within a select type and it does not work. Is there anyway to escape this comma?

    Have an outstanding day!

      1. Thanks for that!

        I'm having the problem of it not rendering correctly after the page is edited. However, when I preview it, it works fine?

        {run:autorun=false|titleRun=Submit|replace=location:$location:Select a Location:select::
        "(`service` = '$metric - United States (US)' OR `service` = '$metric - Miami, FL (US)' OR `service` = '$metric - Orlando, FL (US)' OR "`service` = '$metric - Tempe, AZ (US)')":Overall:
        "`service` = '$metric - United States (US)'":United States (US):
        "`service` = '$metric - Miami, FL (US)'":'Miami, FL (US)':
        "`service` = '$metric - Orlando, FL (US)'":'Orlando, FL (US)':
        "`service` = '$metric - Tempe, AZ (US)'":'Tempe, AZ (US)'}
        {center}
        {run}
        

        Preview

        Live

      2. Bob, any ideas on this issue?

        1. You need single quotes and don't split over multiple lines:

          {run:autorun=false|titleRun=Submit|replace=location::Select a Location:select::' (service = ''$metric - United States (US)'' OR service = ''$metric - Miami, FL (US)'' OR service = ''$metric - Orlando, FL (US)'' OR service = ''$metric - Tempe, AZ US)'')':Overall:'`service` = ''$metric - United States (US)''':United States (US): 'service = ''$metric - Miami, FL (US)''':'Miami, FL (US)':'service = ''$metric - Orlando, FL (US)''':'Orlando, FL (US)':'service = ''$metric - Tempe, AZ (US)''':'Tempe, AZ (US)'}
          $location
          {run}
          
  3. Hi Bob. I'd like to use the run macro to to replace "tags" in chapters of a document, each chapter is on a separate wiki page. The tags are inserted before Figure, Table and Equation numbers, so that Figures in chapter 1 are labelled 1.1, 1.2 etc.. Using this method, I can insert new chapters without having to change all the numbers in the chapters that come after the insert. For example:

    {run:autorun=true|hideRun=true|hideParameters=true|replace=intro:1.,disc:2.,conl:3.} 
    {include:introduction}
    {include:discussion}
    {include:conclusion}
    {run}
    

    However, this doesn't work because the include macro renders each included page before making the replacement. Do you know if there a macro that will include wiki markup from another page without rendering it, or can you suggest another way to do it? Thanks in advance for any suggestions.

    cheers, Phil.

    1. No, I don't know of such a macro, but it would be handy in this situation. However, there is an numbered headings plugin.

  4. Hi!

    I'm trying to use run recursively to first fetch data from a database(using the sql macro) which are then presented to the user before he
    modify the existing data from the database before updating/saving it.
    The code is as follows:
    

    {run: replace=serviceId|hideParameters=true|hideRun=true|keepRequestParameters=true}
    {sql:datasource=myDS|output=wiki}
    select service_name as Service,domain as Dom,description_short as ShortDesc,description as Descr,internal_service_reg_id as sId from ServiceRegister where
    internal_service_reg_id=$serviceId
    {sql}
    
    {run1:heading=Change Service\|prompt=Click to save|keepRequestParameters=true|replace=Service,Dom,ShortDesc,Descr,sId}
    {sql:dataSource=myDS\|output=wiki}
    update ServiceRegister set service_name="$Service", domain="$Dom", description="$Descr", description_short="$ShortDesc" where internal_service_reg_id="$sId"
    {sql}
    {run1}
    {run}
    

    I am using both run and run1, but I am getting no data in the inputfields in the form presented to the user.
    I have (as can be seen) tried to use "keepRequestParameters=true" to help me pass the information from the first run block to the second, but it seems like
    it only passes along the initial input.
    How can I get hold of the output from the first sql and pass it as input to the second?

    Thanks

  5. Hey Bob,

    Is there anything like an if, then, else condition you could use with the run macro? I want to run a different query according to  and after checking input parameters.

    1. No, you need a small script to do that - Scripting for Confluence, I recommend groovy.

  6. Is there something I am missing? I can get the replace to work when I use a text-entry field, but when I switch it to a checkbox, nothing happens. I assume that the replace isn't happening properly with what I am using:

    {run:replace=foo::Category:radio::hotfix:Hotfix:instructions:Instructions}
    {sql:datasource=myDS|output=wiki} select NAME,LABELID from LABEL where NAME='$foo' {sql}
    {run}

    Thank you for any help you can give.

    1. That code works fine for me.

      You will have a problem when you switch to a checkbox because you will be trying to query:

      select NAME,LABELID from LABEL where NAME=''hotfix','instructions''

      Perhaps something like

      select NAME, LABELID from LABEL where NAME IN ($foo)

      would work?

      1. I can take the statement out of 'run' and it works fine with the second example. I still can't get the 'replace' to work, I guess.

        Is there a debug setting or anything that will let me know what is going on? I get no error, just no table when I click Run.

        {run:replace=foo::Category:checkbox::hotfix:Hotfix:instructions:Instructions}
        {sql:datasource=myDS|output=wiki}
        
        select NAME,LABELID from LABEL where NAME IN ('$foo')
        {sql}
        
        {run}
        1. Bob Swift will probably have to answer that. I'm not sure why the macro is not rendering.

          1. Completely user error. I was running it in Preview Mode, but it wasn't working. Once I did a full save, it worked.

  7. One last thing...

    I am able to use this statement perfectly well until I turn autorun on. When I do, the replace doesn't seem to work the same as when I manually click enter.

    {run:autorun=true|hiderun=false|replace='labelenter':'hotfix,instructions,troubleshooting':Category:checkbox::'hotfix':Hotfix:'instructions':Instructions:'troubleshooting':Troubleshooting}
    {sql:datasource=myDS|output=wiki}
     SELECT TITLE FROM CONTENT c JOIN CONTENT_LABEL cl ON c.CONTENTID = cl.CONTENTID JOIN LABEL l ON cl.LABELID = l.LABELID WHERE l.NAME IN ($labelenter)
      {sql}
    {run}

    I receive this error:

    sql: java.sql.SQLException: Invalid column name 'troubleshooting'.
    SELECT TITLE FROM CONTENT c JOIN CONTENT_LABEL cl ON c.CONTENTID = cl.CONTENTID JOIN LABEL l ON cl.LABELID = l.LABELID WHERE l.NAME IN (hotfix,instructions,troubleshooting)
    A couple of other things I noticed:

    • Is it possible to have the 'run' rerun itself after another selection is made, or cleared?
    • Why do the selections clear themselves after you run the query? This is confusing, as the user doesn't know what they selected by looking at the list.
    1. Rhyne,

      The default value you had set didn't contain the correct SQL format. It would try to query:

      WHERE l.NAME IN (hotfix,instructions,troubleshooting)
      

      You must put the single quotes in manually into the default value in order to have the query run correctly when it's auto run.

      This should work:

      {run:autorun=true|hiderun=false|replace='labelenter':'''hotfix'',''instructions'',''troubleshooting''':Category:checkbox::'hotfix':Hotfix:'instructions':Instructions:'troubleshooting':Troubleshooting}
      {sql:datasource=myDS|output=wiki}
      SELECT TITLE FROM CONTENT c JOIN CONTENT_LABEL cl ON c.CONTENTID = cl.CONTENTID JOIN LABEL l ON cl.LABELID = l.LABELID WHERE l.NAME IN ($labelenter)
      {sql}
      {run}
      

      Your other questions will be best answered by Bob.

      1. It does work, except the checkboxes aren't selected. I guess the extra ' around the defaults don't map to the checkboxes.

        1. There is a bug (RUN-67) and fix available for quote handling. The proper markup should be:

          {run:autorun=true|hiderun=false|replace='labelenter:''hotfix'',''instructions'',''troubleshooting'':Category:checkbox::''hotfix'':Hotfix:''instructions'':Instructions:''troubleshooting'':Troubleshooting'}
          $labelenter
          {run}
          
          1. Bob,

            I replaced the markup with exactly what you entered and receive the following error:

            sql: java.sql.SQLException: Incorrect syntax near '&'.
            {run:autorun=true|hiderun=false|replace=labelenter:'&bsp;,''hotfix'',''instructions'',''troubleshooting''':Category:checkbox::'hotfix':Hotfix:'instructions':Instructions:'troubleshooting':Troubleshooting}
            1. Rhyne,

              Can you post your SQL query as well?

            2. typo - &nbsp.... I think you need to wait for a fix for RUN-67 to make this work in your example. I will see if I can get time to look at it this week.

              1. Thank you! I will be watching for that fix. I think this is the answer to what we need and have been searching for for months.

              2. Hi Bob,

                Have you been able to look into making this work?

                Thanks!

  8. Thanks Norbert for your contributions on this topic. Regarding the other points to answer, I think they stem from the original problem.

  9. How can I adjust/massage the replacement value prior to using it?  Specifically, if a user enters a value, how can I convert it to upper case prior to having it replace the replacement tokens?  In the example below, the scaffold data I'm working against, the data for Country is pulled from a select list as all upper case, and when someone runs the report, the report works if they enter, for example, "PAKISTAN" but not "Pakistan".  I just want to upcase the replacement variable prior to replacement.

    {run:replace=Country|titleRun=Search}
    {run {report-block}
    {report-table}
    {report-header}
    h4. An overview of Country Experience for FHI360 for $Country{report-header}
    {local-reporter:content:descendents|types=page|source=Technical Assistance Home}
    {content-filter:labels=-index}
    {or-filter}
     {collection-filter:data:GeoAsia|matchItems=any}
     {text-filter:include=$Country}
    {collection-filter}
    
    ... code continues....
  10. Unknown User (magan_b@mtn.co.za)

    Hi Bob,

    We would like to utilise the run macro for creating a survey/report template but we are unable to obtain the correct formatting for column headings/labels?

    Could you possible provide us with an example of the code required to add multiple column headings to a table using the Run macro

    Thank you for the help.

    Bhavesh

    1. The table you are talking about is whatever markup you use within the body of the Run macro to create the table. You can use whatever techniques you want to create the table with headings. For instance, in wiki markup:

      || h1a\\ h1b || h2a\\ h2b ||
      

      h1a
      h1b

      h2a
      h2b

      1. Unknown User (magan_b@mtn.co.za)

        Thanks Bob, this is useful for displaying an output from a database but we would like to capture input from users using the macro. This works fine however the problem we would like to include the parameter label above the inputbox as currently it shows below the inputbox.

        I have provided an example below.
        '{run:heading=Issue Summary|hideRun=true| replace=g1::Revenue Issues Identified:group:100%, ra_resolved::, ra_unresolved::, ra_total_issues::,
        g2::Fraud Issues Identified:group:100%, fraud_resolved::Resolved, fraud_unresolved::Unresolved, fraud_total_issues:: Total Issues '

        Regards,
        Bhavesh

        1. This is not available with simple options. You would need to provide a customized velocity file and specify it on the parameterInput parameter. You can request an option be added by creating a improvement issue.

          1. Unknown User (magan_b@mtn.co.za)

            Hi Bob,

            Just a quick question about Passing Variables in Hyperlinks using the macro.

            I have created a url with the specified variable I want to pass to the next page and can see it on the url in the navigation bar, but I cannot access the value in any run macro specified on the new page.

            For example,the URL below passes the value of the varible $country to the next page but we cannot read the value.http://raportal.mtn.com/display/Test/RA+and+Fraud+Issues?run_1=run&run_1_country=$country

            run-now:id=1
            sql:datasource=confluenceselect * from Test2
            where country = $country
            sqlrun-now

            Could you please provide us with an example of the configuration for the run macro which is receiving the variables?

            1. You need a replace parameter on the target page's run macro that identifies the county variable.

  11. This macro does not function as Jira Gadget ?


    Hi,

    I created a very simple page:

    {run:titleRun=Execute|replace=user::Reporter:text-required}
    [*Open report*|http://foo.bar/jira/secure/IssueNavigator.jspa?reset=true&jqlQuery=reporter+%3D+%22$user%22+and+resolution+is+empty] 
    {run} 

    wich works fine... but when I use it in a Jira's gadget, a NullPointerException occur, see bellow:

    WWhat is wrong ?

    1. Are you using Confluence page gadget? Please create an issue (issues tab) and document the gadget, JIRA and Confluence release levels.  Thanks.

      1. Hi Bob,

        Created issue:  RUN-71 - Getting issue details... STATUS

  12. I’m trying to use anchor parameter from run; but as I’m using it, it’s not working; can anyone help me see the light

    here’s my code, and yes I’ve got an anchor with “here”name.

    {run:id=dynamic|heading=Ver espaços por intervalo de datas|autorun=false|replace=dtInicio::data Início:text-required,dtFim::data Fim|titleRun=executar|anchor=#here}

    Thanks in advanced

  13. hi bob, thanks for your quick answer.

    that was my first option, but didn't work.

    here the url produced:

    http://wiki.cm-seixal.pt/display/teste/Dados+BD+@confluence?run_dynamic_dtInicio=2010-01-01&run_dynamic_dtFim=2010-12-31&run_dynamic=run#DadosBD@confluence-here
    1. #DadosBD@confluence-here part of the url is the standard link created by confluence for anchors. Compare with using the standard linking produced by #here

  14. Hi, I installed v2.1.0 of Run Plugin via UPM under Confluence 4.2 and the Admin/Plugins page lists it as an enabled plugin without any error note. All 4 modules of the plugin are enabled as well. However when I try to insert the run macro in a page, it is not listed in the available macros. I tried to call it also from a user macro that fails with an "Unknown macro: 'run'" message. Do I need to configure something else in order to be able to use the run macro?

  15. Hi Bob,

    The Run macro (provided by the Run plugin 2.1.0) replaces double quote characters (") in an input text box with HTML entity references ("). I'd rather the original characters remained.

    Example code at Searching Confluence storage format XML for content or markup.

    1. Please create an issue for tracking this. Document your Confluence release. I don't think this has come up before.

  16. Hi,

    I'm trying to us the following code to allow users to search for content based on modification date:

    {run:titleRun=Search|dateformat=dd/mm/yyyy|replace=lastmoddatestart::Start Date,lastmoddateend::End Date}
    {chart:title=Narnia Content|type=line|displayData=true|width=500|height=300|dataOrientation=vertical|pieSectionLabel=%0% - %1%|legend=false|tables=content|attachment=Narnia content.png}
    {sql:dataSource=confluenceDS|id=content}
    select LASTMODDATE, TITLE, CONTENTTYPE
    from CONTENT 
    where LASTMODDATE > '%lastmoddatestart' and LASTMODDATE < '%lastmoddateend'
    and Title is not null and LASTMODDATE in 
    (select MAX(LASTMODDATE) from CONTENT 
    where LASTMODDATE > '%lastmoddatestart' and LASTMODDATE < '%lastmoddateend'
    group by TITLE) order by LASTMODDATE
    {sql}
    {chart}
    {run}

    But I'm getting this error:

    sql: java.sql.SQLException: Conversion failed when converting date and/or time from character string.select LASTMODDATE, TITLE, CONTENTTYPE
    from CONTENT 
    where LASTMODDATE > '%lastmoddatestart' and LASTMODDATE < '%lastmoddateend'
    and Title is not null and LASTMODDATE in 
    (select MAX(LASTMODDATE) from CONTENT 
    where LASTMODDATE > '%lastmoddatestart' and LASTMODDATE < '%lastmoddateend'
    group by TITLE) order by LASTMODDATE
    
    

     

    Any ideas what I'm doing wrong?

     

    Cheers,

    Matt

    1. Use ?lastmoddatestart to get the run variable replacement.

  17. Hi Bob,

    I wasn't sure where to put this (RUN, SQL, Chart) but I think it's RUN-related so hopefully this is OK.

    I have the following code to generate a user-selectable value to use in a chart.  It works fine, except one of the columns has commas in it.  I've tried any number of combinations to make it work, but the SQL doesn't seem to want to play well with Wiki (I think).  I know it's the comma because my regexp_replace works fine when I just replace the comma with nothing.  I'm trying to "escape" the comma, but I'm not sure if this is the right thing to do?

    {groovy:output=wiki}
    import com.atlassian.renderer.v2.RenderMode
     
    def renderMode = RenderMode.suppress(RenderMode.F_FIRST_PARA)
    
    def choiceSql = "select distinct(regexp_replace(stringvalue, ',', '\\\\,', 'g')) || ':' || regexp_replace( stringvalue, ',', '\\\\,', 'g' ) || ':' as choice from customfieldvalue where customfield = 10717 order by choice asc"
    
    def choiceMacro = "{cache} {sql-query:datasource=jiraDS|table=false|output=wiki|escape=true} ${choiceSql} {sql-query} {cache}"
    
    def choices = subRenderer.render(choiceMacro, context, renderMode)
    
    def runMacro = """
    {run:id=dynamic|autorun=true|titleRun=Display|suppressQuote=true|replace=Department:Call Center:Choose Department:select::${choices}}
    {chart:type=line|title=Tickets by Department|subTitle=(based on issue types created)|height=400|width=1700|3D=false|tables=content|dataOrientation=vertical|dataDisplay=after}
    
    {sql-query:datasource=jiraDS|id=content|output=wiki}
    
    select substring(jiraissue.created::text from 1 for 7) as \"Month\", count(distinct (jiraissue.id)) as \"Count\"
    from jiraissue, customfieldvalue
    where ( customfieldvalue.issue = jiraissue.id )
    and ( customfieldvalue.customfield = 10717 )
    and ( customfieldvalue.stringvalue like \'\$Department%\' )
    group by substring( jiraissue.created::text from 1 for 7 )
    order by substring( jiraissue.created::text from 1 for 7 );
    
    {sql-query}
    {chart}
    {run}
    """
    
    println runMacro
    
    {groovy}

    If you have any thoughts I'd be grateful.

    Thanks,

    Stuart.

    1. I think I understand your question - the comma may be in your choices and comma is a delimiter in the run macro replace parameter. For that, you need to quote correctly. 

      replace - A comma separated list of key:value:description triplets. Any entry containing a comma (,) or colon (\:) must be enclosed in single quotes (') - example: x:1:'It''s an example: 1, 2, or 3'.

      So, your select should guard against that by quoting: ... select::x1:'x1 choice with , in it':x2:'another choice': ...

      Make sure your run looks and works correctly in isolation before combining with the rest of it. If your choice text may also contain single quote, then it is more difficult since you will then have to construct the sql to escape the embedded quote as well (ie double it) using a replace technique similar to what you have above.

  18. Hi Bob,

    Thanks for getting back to me so promptly.  Yes, you were right, the comma was in the choices macro - this is because it is in the SQL table data and so was being used accordingly.

    I have added single quotes around the SQL, so it now looks something like this (note the extra single quotes after/before the colon):

    def choiceSql = "select distinct(regexp_replace(stringvalue, ',', '', 'g')) || ':''' || regexp_replace( stringvalue, ',', ',', 'g' ) || ''':' as choice from customfieldvalue where customfield = 10717 order by choice asc"

    (I know there are mistakes in this but I've left them in until I get it working.)

    So this has essentially resolved the issue for the "value" portion in the "key:value:description" triplet.  The problem is that I seem to need to surround the "key" portion as well, and SQL won't let me do that?  eg '" select ''' || distinct ..." isn't valid.

    Am I on the right track here - and is there any way to do that?

    (As an aside, Postgres is also returning "&amp;" instead of "&" which is upsetting the apple cart too.  psql returns the right thing - do I need to set some value for this?)

    Thanks again for your help Bob,

    Stuart.

    1. Try select distinct on (key) '''' || key || ''''
    2. Don't know about the & thing  
  19. I'm seeing odd behavior with the checkbox. Given the code below to specify a checkbox input:

    grpName::Group Name:checkbox:3:AVal:A Text:BVal:B Text:CVal:C Text:

    when I check one of them the output is, for example when I check BVal:

    'BVal','BVal'

    Essentially its giving me the value twice.  Any ideas? 

     

    1. This works for me. See if it does for you. If so, then something else is wrong in your other variables, perhaps a duplicate name? If you still have issues, open a support issue with more details including your plugin and Confluence version, etc... 

      {run:replace=grpName::Group Name:checkbox:3:AVal:A Text:BVal:B Text:CVal:C Text:|autoRun=true}
      $grpName
      {run}
      1. Hey Bob - 

        I created RUN-79 to track it.  I tried what you said and got the same result.  I will say that when I entered a default value and also turned on autoRun, when the page initially loads  it shows it correctly, but when I select another checkbox and click Run, it displays 'foo','foo' again.  

        I tried this on Confluence 4.3.2, and I tried both 2.1 and 3.0 of the plugin. Also, I am putting this on a page in my personal space and its contained within a "Wiki Markup" macro, because I didn't think this macro supports the new macro parameters.

        Thanks, and good luck!

  20. {run:replace=Search:::text}
    {sql:dataSource=ConfluenceExtDS|output=html}
    SELECT * FROM ExampleTable et WHERE et.ExampleVarChar LIKE '%$Search%'
    {sql}
    {run}

    Besides being textbook SQL injection this chokes on single quotes. Is there any way to get use a more parameterized approach? You can set this up as a parameterized query but you still have the same problem of getting the string to the server.

    1. You need to be careful with how you do things with untrusted users. Specifically with SQL you should use SQL parameter markers.

  21. Need some help trying to use Run Plugin within Reporting Plugin...

    Running Confluence 5. I have a set of attachments to a specific page and assigned labels to each attachment (a much-appreciated new Confluence capability over our old version).

    I would like to present to users a list of available attachments and let them filter that list based on their checkbox selections (filter by attachment labels).

    What I have so far:

    {run:autorun=true|replace=c1::Choose one or more filters:checkbox:99:prod1:Product 1:prod2:Product 2:datasheet:Datasheets:casestudy:Case Studies}
    {report-list} 
    {content-reporter:labels=$c1|types=attachment|scope=a specific page} 
    {content-reporter} 
    {report-body} 
    {report-info:attachment:title} 
    {report-body} 
    {report-list}
    {run}

     

    The checkbox prompt appears properly and the titles of all page attachments appear as follows:

    But if I click on a box and Run... nothing is displayed. Note the above reporting plugin wiki markup works fine without '{run}' (that is, using a specific value for labels within content-reporter).

    I'm just getting started trying to use Run Plugin and really appreciate the help.

     

    1. Never mind... I figured it out... content-reporter doesn't like quotes! 

      Now with suppressQuote set to TRUE... works fine. (smile)

      One extra edit: added a plus-sign in front of all of my labels:  +prod1 etc... otherwise content-reporter will return attachments containing any of the selected labels (OR)

       

  22. Bob, actually I do have a question...

    I would like to organize user options by category... for example:

    However, (referencing my wiki markup in above posting) when I try to insert the results of the above two sets of checkboxes (c1 and c2):

    {content-reporter:labels=$c1,$c2|types=attachment|scope=a specific page} 

    I don't get any results.

    $c1,$c2 in the above Wiki markup must result in a set of results with commas... with a comma in between $c1 and $c2. Further muddying the waters is I don't want to require the user to make selection(s) for c1 and/or c2.

    Note that beyond the above markup I am also suppressing quotes through the Confluence5 prompt-no issue there.

    Thanks for your suggestions!

     

     

    1. To debug, make sure you see exactly what the replacement for each case is going to look like and that the content-reporter macro gives you the result you expect with that replacement. I usually do that kind of thing by comment out the macro (when using wiki markup) by putting a backslash in front. I would guess you are going to get labels=, if there are no selections and a comma separated list with one or more selections. Perhaps the content-reporter macro doesn't like extra commas at the beginning or end.

      1. Thanks Bob. I think dealing with this requires some if-then logic to display certain commas or not. Any suggestions to point in right direction?

        1. So, content-reporter doesn't like the extra commas? Well, you could certainly ask for them to improve that. In the mean time I think you would have to go with a user macro or script to repair the input prior to given it to content-reporter. By that, I mean, wrap all the reporting macro stuff into a user macro or script macro so you can do the logic and then render the entire block.

  23. We have numerous pages using SQL macro wrapped in RUN macro.  Very useful!  I believe at one point (but I can't prove this) that we had the ability to export the SQL output after run to a PDF, but this no longer seems to work (either in our current 3.0.2 Confluence instance or in the test 5.1.2 instance that we're preparing to migrate to).  Is is possible to do this or am I dreaming that it used to work?  Pages with static SQL macro (without RUN) export to PDF just fine.

    Thanks -

    1. I don't think this ever worked in general. This is reported as RUN-43. The export is a new rendering of the page which does not have the parameters set. Only the default rendering will show in the export. I am not sure what can be done via the generic export. An alternative is to provide an export to PDF like the current HTML support.

      1. Thanks Bob - I appreciate you looking into this.  It is indeed possible that I dreamed that this once worked and that it was only on pages with static SQL.  It's not a big issue in any event - it just came up during our upgrade testing and I'll now simply close it out.  Once again, thanks for the great support.  I'm happy to have us paying the license fees for your plugins knowing that we've got someone that stands behind their product.  I wish that was the case with all paid plugin vendors...

  24. I would like to be able to pass exportFile as part of the URL...is this possible

     

    when using link below my results are still saved in 'default file location' (browser-stats.html in my case)

    /SQL+Plugin+Test?run_1_startDate=7/1/2013&run_1_endDate=7/31/2013&run_1_exportFile=^browser-stats-2013-07.html&run_1_exportVersion=replace&run_1=export

    1. Sorry, I must have missed this post. 

      This looks like a bug to me. I opened RUN-106 for you.  

  25. I am having an issue getting the correct output from Radio and Select fields. The output from text fields works fine, but the output for the others yields the key for the corresponding value selected. I have double-checked my markup and compared to the documentation but can't figure out what I'm doing wrong. Here is a snipet of my wiki markup:

    {run:autorun=true|heading=Cisco 38xx Router Configuration Variables|titleRun=Preview configuration|titleExport=Export configuration to file (attached to this page)|exportFile=^$hostname.html|
    replace=
     hostname::Hostname,
     timezone::Time Zone:radio::zone1:EST -5&nbsp&nbsp&nbsp:zone2:CST -6&nbsp&nbsp&nbsp:zone3:MST -7&nbsp&nbsp&nbsp:zone4:PST -8&nbsp&nbsp&nbsp:zone5:AKST -9&nbsp&nbsp&nbsp:zone6:HST -10}

    !!!!! Configuration generated by $current_user_name on $current_time
    !
    !
    hostname $hostname
    !
    clock timezone $timezone
    !
    {run}

    Note that the 2 fields are actually indented with a tab that doesn't show up here. So whatever I enter for the hostname shows correctly, but if I for examlpe select the radio for "MST -7" the output is "zone3".  I must be missing something.

     

    Also, is there a way to export the output as a text file attachment to the page instead of HTML?  I tried, but it comes out as one continuous string with "<p>" and "<br/>" for line breaks.

    1. The first part of the pair is the value to show on replacement and the second part is the text shown to the user. So, in your case you probably want something like:

      timezone::Time Zone:radio::EST -5&nbsp;&nbsp;:EST -5 ...

      Regarding your second question, no, export can just export the HTML (just as it is produced for the display after substitution).

      1. First off, thank you very much for your support and quick response! I am testing several of your plugins so I can demonstrate their usefulness so we can get them purchased. Your timely responses are very much appreciated.

        OK, now I see my issue, thanks so much for the response and example. I misread and thought it required the same key:value:description combination, but after re-reading I see it's just value:text.  Regarding not being able to export to a text file attachment, I was hoping to automate it so the text file is ready to go for the engineers, but I guess I can have them open it in a text editor and find/replace the  "<p>" and "<br/>" tags. Unless someone knows a better workaround.

        So one more quick thing if I may...I'm new to Wiki markup and learning as I go.  I noticed you used ';' semicolon after the &nbsp required spaces I inserted. Initially, I didn't see a better way to add spaces between the radio options; it doesn't give much separation without those. So your ';' notation led me to believe there may be a way to separate the added spacing from the field parameters. However, I cannot figure out how to do it properly.  I would prefer to only have to specify the Value parameter and leave the Text parameter blank, yet still provide 3 spaces between each radio option. Along the lines of:

          timezone::Time Zone:radio::EST -5:EST -5;&nbsp&nbsp&nbsp;:CST -6:CST -6;&nbsp&nbsp&nbsp;:MST -7....
        or

          timezone::Time Zone:radio::EST -5;&nbsp&nbsp&nbsp;::CST -6;&nbsp&nbsp&nbsp;::MST -7....

        Note that I have done quite a bit of searching and trial-and-error testing before posting here, but so far I can't find out how to mark it up properly.

        1. Use style macro before the run macro on the page with something like:

          input[type="radio"] {
              margin-left: 20px;
              margin-right: 5px;
          }
          1. That was very helpful, and it works perfectly. Thank you! (smile)

  26. Hello again Bob,

    Folks have seen the value of this plugin and we will be purchasing. (wink)  I am finding new ways to use it every week.

    I am still looking for a way to export the Run macro output to a text file without the tags...just the text. The desire is to generate a script based on the parameters the user chooses (which the Run macro does nicely), and then save the output to a text file so it can be pasted via CLI or loaded onto flash/NVRAM of a network device. I have searched a lot and found very little. However, it looks like the exportData function of the Confluence CLI plugin might be able to do this. I can't tell for sure based on the examples, and I don't know how well it would play with the Run macro (either inside the macro, or used after the macro to export just the Run macro output). Any guidance you can provide here?

    1. Thanks for the feedback (smile). There are a few examples of using run with CLI - for example: How to set up a self service CLI page for Administrators. You can always use the Scripting for Confluence to construct whatever data you need from the run parameters for specialized needs.

      1. Thanks for the reply. I was hoping to stay away from scripting, but if there is no other way I will look into the Script Plugin (and Beanshell I guess...not sure which is the best to use). I also left a review. (wink)

  27. Hi Bob,

    I am using 2.0.2 with Confluence 3.3.1 (yes, rather old). Trying to fill two inputs fields with current date in yyyy-mm-dd format.

    This doesn't work, could you correct me?

    {run:replace=startdate:$current_time:Start Date:Year|dateFormat=yyyy-MM-dd,enddate:$current_time:End Date:Year|dateFormat=yyyy-MM-dd}
    You entered: $startdate $enddate
    {run}

    In addition, I found "Year|dateFormat=yyyy-MM-dd" in one of your comments above, but I can't interpret it from documentation on this page.

    Thanks in advance.

     

    Year|dateFormat=yyyy-MM-dd
    1. Hard to say what was supported back then, but this does work with current support.

      {run:replace=startdate:$current_time:Start Date:Year,enddate:$current_time:End Date:Year|dateFormat=yyyy-MM-dd}
      You entered: $startdate $enddate
      {run}
      1. Thanks for the quick reply, that actually works! I guess you only have to specify "|dateFormat=yyyy-MM-dd" once for the whole "run" macro.

        My $.2: This documentation made no mention how to apply dateFormat, especially no mention of the pipe ("|") character.In addition, several links to Date Format on this page are outdated.

        1. Yes, that is standard wiki markup notation (pipe being a parameter separator). Thanks for pointing out those old links. I have updated those.

  28. Hi Bob, I am trying to export a SQL Result Set as attachment but all spanish characters are wrong. I am trying several encodings in File Encoding Box but it doesn't seem to work. Am I missing something?

     

    Best Regards

  29. Hello again Bob, and congrats on the Appfire thing. (smile)

    I have noted in the docs above for checkboxes (and other multi-select fields) that "The replacement value for such a field is a single quoted, comma separated list of single quoted selected values". Is there a way to strip the single quotes from the replacement value? I am trying to use Run to provide a standard list of labels for a user to select for a page (see markup below). The labels they select from the list will feed into the (Label Tools) Add Label macro, which is looking for a comma-separated list. The replacement value provides the needed comma between each label they select, but also adds the single quotes, which ultimately gets added as part of the label to the page. The end game is to use Adaptavist's Advanced Search plugin to allow users to search for pages containing a variety of labels (and other criteria). Any ideas? Here's my markup:

    {run:autorun=false|heading=Suggested Labels|titleRun=Add Label(s)|
    replace=
    	labelstoadd:noselection:Select one or more labels:checkbox-required::label1::label2::label3::label4::label5::label6::label7::label8::label9::label10::label11::label12::label13::label14::label15::label16::label17::label18::label19::label20}
    
    Results:
    $labelstoadd
     
    {add-label:labels=$labelstoadd}
    {run}
    1. Thanks. Yes, use the suppressQuote parameter.

      1. I completely missed that, Bob. Thanks for pointing it out...works great now.

  30. Bob, sorry for the long post, but hopefully it is enough to explain what I'm trying to do. I am using the Run and Add-Label macros to create a user macro that can be applied to any page to add a standard set of labels. I need to have different categories of labels, yet not require the user to pick from every category (i.e. I don't want to append -required to the checkbox type). The functionality works like I want, but I still get an error (as expected) for any label category with no selection. Here is the example wiki markup I created and the results:

    {run:autorun=false|heading=Standard Labels|titleRun=Add Label(s)|suppressQuote=true|
    replace=
    	colorlabelstoadd:noselection:Add Color Label(s):checkbox::red::white::blue,
    	sizelabelstoadd:noselection:Add Size Label(s):checkbox::small::medium::large::1X::2X::3X,
    	stylelabelstoadd:noselection:Add Style Label(s):checkbox::short-sleeve::long-sleeve::hooded::v-neck::tank-top}
    
    {add-label:labels=$colorlabelstoadd}
    {add-label:labels=$sizelabelstoadd}
    {add-label:labels=$stylelabelstoadd}
    {run}

     

    And here is the Confluence storage format I'm using for the user macro (using 'Escaped' for the Macro Body Processing option), which yields the same results shown above when adding the macro to a page:

    ## @noparams
     
    <ac:macro ac:name="wiki-markup"><ac:parameter ac:name="atlassian-macro-output-type">BLOCK</ac:parameter><ac:plain-text-body><![CDATA[{run:autorun=false|heading=Standard Labels|titleRun=Add Label(s)|suppressQuote=true|
    replace=
    	colorlabelstoadd:noselection:Add Color Label(s):checkbox::red::white::blue,
    	sizelabelstoadd:noselection:Add Size Label(s):checkbox::small::medium::large::1X::2X::3X,
    	stylelabelstoadd:noselection:Add Style Label(s):checkbox::short-sleeve::long-sleeve::hooded::v-neck::tank-top}
    
    {add-label:labels=$colorlabelstoadd}
    {add-label:labels=$sizelabelstoadd}
    {add-label:labels=$stylelabelstoadd}
    {run}]]></ac:plain-text-body></ac:macro>

     

     I would like to include an "if/then" statement for each, but I have researched this quite a bit and cannot find a solution. I found something similar here (https://confluence.atlassian.com/display/DISC/watermark) and tried changing the 3 'add-label' sections as shown below, but that didn't work at all (error processing the user macro). Obviously I don't know what I'm doing, but my assumption is these are two styles of code and you can't mix them. So my question to you is how can I add 'if/then' type statements to prevent the 'add-label' macros from executing if nothing was selected for a particular label group?

    #if ($colorlabelstoadd != 'noselection')
    #{add-label:labels=$colorlabelstoadd}
    #end
    #if ($sizelabelstoadd != 'noselection')
    #{add-label:labels=$sizelabelstoadd}
    #end
    #if ($stylelabelstoadd != 'noselection')
    #{add-label:labels=$stylelabelstoadd}
    #end
  31. How do I pass a value to a Jython script where the script isn't inline but a file stored in the script folder?

    I've specified "replace=s1:choice:?Choose:select:A:A:B:B:C:C" and then referenced s1 in the script:

    print "Selected letter is '%s'" % s1
    exit()

    but when I click on the Run button, Jython complains that s1 isn't declared.

     

     

  32. Hi Bob.  I’m hoping you can help with the following and I apologise if this is the incorrect place for this question as based on what I'm doing it could be any one of 3 places.  For reasons too complicated to go into here, I need to query a JIRA and another database (both MS SQL Server), normalise and amalgamate the results and output to a confluence page for reporting purposes.  This I have already done by having a run macro, with multiple input parameters, call, and pass parameters to, a sql-query macro which in turn calls an inner sql macro which starts doing the work before passing results, in a long string, back to the calling sql-query macro which, splits the string and rebuilds temporary tables and does some queries of its own based on the return to eventually build up the report.  By the way this was achieved because I listened to a few of your simple rules (start small and make sure the inner macro is doing what you expect before wrapping it in another).  Now I want to take this to the next level because I don’t want to be constantly administering the parameters on the run macro nor setting this up again and again for every project that spins up.  So what I want to do in its simplest form is

    • Present the user with a single dynamic dropdown list based on the values in a database table (JIRA projects) – I can do this with Groovy embedded with a sql-query followed by Run, execuetd via println, based on the rendered query
    • When the user selects the project – query the database to build up another select list (say JIRA fix-version -- in practice I want to present about 5 fields from, maybe, two different databases with choice values based on the project chosen )
      • Something like – and I tried all in vain (it’s very likely because I’ve never programmed in Groovy or Java or similar and I have minimal API knowledge)
        • Groovy with an embedded run whose parameter list is based on a rendered query with the output of the run passed to a groovy variable which could be then used to run more queries which when rendered get used as input to another run
        • Groovy, again with an embedded run based on a rendered query, with an if statement based on a parameter from the full url which gets passed into a groovy variable
        • Run based on a static selectable project list via the run parameter with an embedded groovy script which based on the chosen parameter runs queries to populate the parameters, via println, of the then embedded second run macro which does some work based on the chosen values and returns the output to the screen
          • This appears to work until I press run on the embedded second run macro which becomes visible after I press run on the first run macro.  After pressing run on the second run macro nothing interesting appears to happen, by that I mean the second run macro's output never ends up on the screen

    By now I’ll bet you can understand my frustration but do you know how I can get around this?  Any help is more than appreciated

     

    1. Well, you are ambitious (smile). A couple of quick points here and then best to open a support issue to track further discussions.

      1. When using multiple (embedded) run macros, make sure you are using the appropriate keep... parameters
      2. Nothing I read would indicate this cannot be done, but, it does require some significant scripting
      3. I am glad the building approach worked for you. Can you simplify the part you are stuck on to make sure the mechanics work? 
      4. Create an issue and attach one or more of your attempts (as simple as you can make them). Secure the issue if you don't want to share that publicly. If you are not using wiki markup, then provide the storage view (requires the source editor plugin to be installed) from View -> Show storage format 
         
      1.  

        Hi Bob,

        Ambitious can be a difficult word to live up to sometimes but I do like trying (smile).

        Based on your feedback above and some extra time to make sure I was keeping it simple and adhering, as best I could, to what you suggested I got a little further but am still stuck on the final hurdle.  I opened RUN-145, which I hope chosing the default priority of Major was correct, which when resolved will hopefully solve what I need and act as a good example, for others, of the power of combining these macros.

  33.  Hi Bob,

     Is there any way of creating a link to a subsection from a page and be able to jump to that subsection from another part of the page even if the subsection is done using "Expand" macro and the section is not expanded?

    The current problem with Anchor is that if user's Anchor is within an Expand section and the section is not expanded when viewing the page, jumping to the Anchor does not work (sad)

     

     Regards,

    Ionut

    1. No, I don't know of anything that can be done there. At least not with the way expand works. Here is a reference link.