Child pages
  • Using Confluence templates with ConfiForms and avoid configuration duplication

Versions Compared

Key

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

In this tutorial you will learn how to use Confluence templates with ConfiForms

Warning

There is a bit simpler tutorial about the concept of using Confluence templates within ConfiForms, Advanced integrations with IFTTT macros with ConfiForms

...


You can reference Confluence templates from:

...

Referencing Confluence templates (what is Confluence template? Read more here https://confluence.atlassian.com/conf57/working-with-templates-701434852.html) is done as follows:

Code Block
[template.TEMPLATE NAME AS YOU SEE IT in TEMPLATES FORM]

Please be aware that the contents of the template will be evaluated against the values in the record used to create a page using this template, but you can include it without evaluating the parameters from ConfiForms version 1.47.2

Info

Status
colourGreen
titleFrom version 1.47.2

You can include the template without evaluating it's parameters.

Code Block
[rawtemplate.TEMPLATE NAME AS YOU SEE IT in TEMPLATES FORM]

The contents of the template "TEMPLATE NAME AS YOU SEE IT in TEMPLATES FORM" will be included as-is, sometimes this is very handful, especially when you create pages with other ConfiForms Forms and have included instructions to use [entry.field_name] or IFTTT results


The logic to find the right template is as follows:

  1. Look by the template name in the current space
  2. If not found then look by the name in the global templates


Info

Status
colourGreen
titleFrom version 2.25.4

You can also set the space key explicitly

Code Block
[template.SPACEKEY::TEMPLATE_NAME]

Same goes for raw template referencing

Code Block
[rawtemplate.SPACEKEY::TEMPLATE_NAME]

This way ConfiForms will attempt to look into the given space to find the template and if not found then the default discovery logic will be used (see above)


For example, a template is named: "My first template"

...

Code Block
[template.My first template]

 


Now we will proceed with the ConfiForms Form setup, which will use the same template for customizing the form, creating the page which shows the page the form with same layout and we will also send an email which will reuse the same template for form layout with some additional information.

 


Let's start with form configuration (if you a new to ConfiForms please have a look first at Creating a simple form in Confluence with ConfiForms tutorial). It will be a ConfiForms form with 3 fields:

...

The content of this template is the following:

Info

FROM VERSION 1.47.2

You can include the template without evaluating it's parameters.

[rawtemplate.mytemplate]

The contents of the template "mytemplate" will not be evaluated against the current record, but will be included as-is



This gives us the unified view of the form in the page created, email sent and when user fillins the form

 


The page created:

And the email sent with the same content

...

If you need to mimic the page in Confluence you will need to add custome CSS styles into IFTTT body macro

 

 



Expand
titleComplete solution in storage format can be found here:
Code Block
<ac:structured-macro ac:macro-id="87547728-9eca-49b5-8b3a-842168920b66" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f</ac:parameter>
  <ac:rich-text-body>
    <p>
      <ac:structured-macro ac:macro-id="a26ca8e6-514d-476a-b1cd-b03914bb8c47" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">subject</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Subject</ac:parameter>
        <ac:parameter ac:name="type">text</ac:parameter>
      </ac:structured-macro>
      <ac:structured-macro ac:macro-id="59f8f010-45de-47db-92ec-9ac567ecd074" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">msgdetails</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Message details</ac:parameter>
        <ac:parameter ac:name="type">wysiwyg</ac:parameter>
      </ac:structured-macro>
      <ac:structured-macro ac:macro-id="40cc9a55-bfc5-4abc-8e6c-a8b452c87264" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">choice</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Choice</ac:parameter>
        <ac:parameter ac:name="values">false[1=Choice 1|2=Choice 2|3=Choice 3|]</ac:parameter>
        <ac:parameter ac:name="type">select</ac:parameter>
      </ac:structured-macro>
    </p>
    <ac:structured-macro ac:macro-id="4697ec46-2f85-459e-8350-0462b846b840" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="action">Create Page</ac:parameter>
      <ac:parameter ac:name="event">onCreated</ac:parameter>
      <ac:parameter ac:name="title">[entry.subject]</ac:parameter>
      <ac:rich-text-body>
        <p>Hello<strong> [entry.createdBy.fullName]</strong>
        </p>
        <p>
          <span>[template.mytemplate]</span>
        </p>
        <p>
          <span>
            <ac:structured-macro ac:macro-id="4ed7249e-7ba0-4b5d-9e66-9ad7e4c624f1" ac:name="confiform-entry-edit" ac:schema-version="1">
              <ac:parameter ac:name="inline">true</ac:parameter>
            </ac:structured-macro>
            <br/>
          </span>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <ac:structured-macro ac:macro-id="cc2cd11f-31f3-4197-9471-53e6b7e25373" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="action">Send Email</ac:parameter>
      <ac:parameter ac:name="event">onCreated</ac:parameter>
      <ac:parameter ac:name="who">sasha@vertuna.com</ac:parameter>
      <ac:rich-text-body>
        <p>This page was created from a <strong style="line-height: 1.42857;">Confluence template</strong> by <span style="line-height: 1.42857;"> [entry.createdBy.fullName] on <span> [entry.created.formatDate(dd.MM.yyyy HH:mm)]</span>
          </span>
        </p>
        <p>
          <span>[template.mytemplate]</span>
        </p>
        <p>
          <span>
            <br/>
          </span>
        </p>
        <p>
          <span>The page can be found here:</span>
        </p>
        <ac:structured-macro ac:macro-id="36e9dcc9-8ea0-48e6-942f-d267a90550db" ac:name="html" ac:schema-version="1">
          <ac:plain-text-body><![CDATA[<a href="http://localhost:1990/confluence/pages/viewpage.action?pageId=${iftttResult_0.id}">${iftttResult_0.displayTitle}</a>]]></ac:plain-text-body>
        </ac:structured-macro>
      </ac:rich-text-body>
    </ac:structured-macro>
  </ac:rich-text-body>
</ac:structured-macro>
<p>
  <ac:structured-macro ac:macro-id="cd00333a-69b4-4156-9d85-3f6f6b5f4e55" ac:name="confiform-entry-register" ac:schema-version="1">
    <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
    <ac:rich-text-body>
      <p>[template.mytemplate]</p>
    </ac:rich-text-body>
  </ac:structured-macro>
</p>

 

 

...