Page tree

Versions Compared

Key

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

...

  • The ConfiForms Form is used as a container as alway, and in our case here uses standard settings. We have only set the form title to be "Create new page" and named our form as "templateengineform"
  • Next is ConfiForms Registration Control, to enable "Register/Add New" button. We place it inside the form container and have it with default settings, but as usual you can set permissions who can use this button, restrict it to be visible for certain groups or users
  • Next 5 macros are the field definitions

    1. Text field to store the page title and use it as the name for the page to create


    2. Hidden HTML field which is not shown on the dialog, but needed for us to store the link to created page


    3. Field to set status on the page - so users know exactly what content they are reading: is it draft, approved and final or just a completed, but not yet approved document


    4. Labels which will be applied on the created page

    please note that we also set separator parameter to be ",". This is needed to enable correct handling of labels - otherwise when multiple labels are selected they are set as one Confluence label, not as multiple 

    5. Formula field to keep the information about when the record has been last time updated
  • There is a ConfiForms Field Definition Rules macro which simply preselects a "draft" status fro you when a dialog to create new page is shown

    a small trick here is that it sets a status value to "default", as this is the colour selected to show a draft status. Check the Documentation for Status field type to see the colours and corresponding values
  • Then there is an IFTTT macro to create a page

    we set page title to be dynamic and based on the value entered on the form, in the field "title"

    and we also set labels to be dynamic as well (Label field definition has a value separator set to "," , so the labels param get's given as a comma separated list)
    The layout we have for the new pages is very simple (for demonstration)

    When page is created it looks something like this: 
  • OK, and the last bit is the ConfiForms IFTTT macro as well, which looks in the Confluence editor like this, because of the ${} construction used in macro parameters

    Actually it is the same IFTTT macro as the fisrt one, but does a little bit different thing: it updates the original ConfiForms record and uses the result of a previous IFTTT macro execution (which is a created page, and the page object which is stored in the variable ${iftttResult_0}, and we use it's property "id", ${iftttResult_0.id}, which is actually a page id of the page which was created)

    In edit mode the macro looks like this:

    Important bits are: the action it does and the parameters

    Code Block
    entryId=[entry.id]&linktopage=<a href="http://your_server/confluence/pages/viewpage.action?pageId=${iftttResult_0.id}">[entry.title]</a>

    As you can see, it updates the entry based on the entry.id and updates one of the entry fields with this HTML link

    Where 

  • [entry.id] is replaced with record id of the record created

  • ${iftttResult_0.id} uses a result of the previous IFTTT macro execution, and it is a pageId it asks for

  • [entry.title] is replace with a page title (which is entered on the form)


Warning

Better solution would be to have a "page/blogpost" field on your form and save the created page id to this field


Let's say we have a field of this type called "mypage". In this case to update it with newly created page id you will do something like


Code Block
entryId=[entry.id]&mypage=${iftttResult_0.id}




When the new page is to be created the dialog looks like this

...