How to go to another location on Run button push

Using run parameters to determine a page to go to when the run button is pressed.


Alternative 1


  1. Create a user macro goto-url
    • No macro body
    • Output HTML

      <script type="text/javascript">location.replace('$paramurl');</script> 
  2. Determine the url you need
  3. Create the run markup as needed


{run:replace=name:My new page|titleRun=New page}



Getting Confluence urls to use

Any macro that produces a link on a page can be used to create a url to use in this scenario. For example the add-page macro can create some complex urls for creating pages with various parameters. Use this macro on some test page to get the url you want. Copy and paste into your run macro markup substituting run parameter values - user defined or Pre-defined variables.

Alternative 2

This uses a more complex user macro to extract the link from the body and then redirect to the referenced link.


  1. Create a user extract-link user macro or use the extract-link macro from Run Self-Service Reports for Confluence.
    • Has macro body - use Convert wiki markup to HTML so it will render embedded macros and markup
    • Output HTML

      ## Macro to search the body text for the first element that looks like a link.
      ## Finds any quoted (single or double) http:// or https:// link or href= value
      ## Returns the unquoted value as raw text or locates to the link if redirect=true
      ## @param redirect:title=Redirect|type=boolean|desc=Redirect to link|default=false
      #set ($body = $body.trim())
      <script type="text/javascript">
      var regex = /['"](http[s]{0,1}:\/\/[^'"]*)['"]/;   // http type link
      var match = regex.exec('$body');
      var redirect = ('$paramredirect' == 'true')
      if (!match) {  // no http type link found
         regex = /href=['"]([^'"]*)['"]/;      // href link
         match = regex.exec('$body');
      if (match) {
          if (redirect) {
              try {
              } catch (e) {
                  document.write('Error: ' + e.message + '. ' +  match[1]);
          } else {
  2. Create the run markup as needed
  3. Create the body of the run macro so that it produces the link desired.


{run:titleRun=Show going to a page on button press|replace=page:home}
{extract-link:redirect=true} Some text [$page] some more text {extract-link}
{run:titleRun=Create a page|replace=name:example}
{add-page:name=$name|template=template1|parent=@self}This is ignored{add-page}