Dynamic page header using a metadata value and triggers
Overview
Using metadata and triggers together can be used to extend the functionality of your workflow.
In this example, we are going to set the workflow to add a page header to the content that changes each time the workflow state changes.
The page header content can be set as metadata, and we can use a trigger to change its value.
The workflow has been configured to display a different page header in each workflow state.
The page header changes on each state transition.
This example utilizes:
A set-metadata macro for a
pagecreated
event trigger to create and initialize the value for metadata namedPage Header
A workflow pageheader macro whose value is the metadata
Page Header
valueThree trigger macros to change the metadata
Page Header
value on different event trigger transitions
Initialize a metadata value for the page header content
The metadata must be initialized using the set-metadata
macro.
This can be done by adding a pagecreated
trigger.
{trigger:pagecreated}
{set-metadata:Page Header}
{color:#FFFFFF}.{color}
{set-metadata}
{trigger}
This simply sets the value of the Page Header
metadata to be a white full-stop.
The Page Header
metadata is added to the workflow pageheader
macro using the get-metadata macro.
You add the macro to the workflow page header in the workflow builder:
In workflow builder, this is displayed as a Page Layout item for the workflow.
When the workflow is applied as a space workflow, when a new page is created, the document has a page header added by the workflow that is simply a white full stop. The viewer does not actually see anything.
In the markup editor, the workflow includes the added pageheader
macro.
{pageheader:visibility=all}
{get-metadata:Page Header}
{pageheader}
It is also easy to initialize a metadata value by using initial=true
in an event trigger, such as a statechanged
event. This sets the metadata value on the first occurrence of the event. It's a useful alternative if you are adding the workflow as a page workflow rather than using a pagecreated
event trigger in a workflow applied in space mode.
{trigger:statechanged|state=In Progress|initial=true}
{set-metadata:Page Header}
{color:#FFFFFF}.{color}
{set-metadata}
{trigger}
Add a Page Header
metadata value for each state change
Second, we are adding a statechanged
event trigger for each state change and using a set-metadata
macro to update the value of the Page Header
metadata in each of these triggers.
In Progress state page header
On the statechanged
event trigger, listening for the transition to the In Progress state.
{trigger:statechanged|state=In Progress}
{set-metadata:Page Header}
||Document Status|@pagestatus@|
||Author|@author@|
||Version|@version@|
{set-metadata}
{trigger}
The trigger action is a
set-metadata
macroThis action macro sets a new value for the
Page Header
metadata
The Page Header
metadata value is a table of value references listing content and workflow information
@pagestatus@
is the workflow status displayed as a breadcrumb@author@
is the creator of the content@version@
is the Confluence version number
This displays the following page header when transitioning to the In Progress state from the initial Draft state in our workflow.
You need to refresh the page after the transition for the page header to be updated.
Approved state page header
On the statechanged
event trigger, listening for the transition to the Approved state.
{trigger:statechanged|state=Approved}
{set-metadata:Page Header}
||Document Status|@pagestatus@|
||Approved by|@Review>approvers@|
||Version|@version@|
{set-metadata}
{trigger}
The Page Header
metadata value is a similar table of value references listing content and workflow information as used in the In Progress statechanged
trigger.
This time it includes an attribute reference:
@Review>approvers@
to retrieve the users who undertook the approved decision as part of the Review approval in the In Progress state
If more than one reviewer was assigned to the Review approval, the header displays all users who made the approval decision.
Draft state page header
In our workflow, the transition from the Approved state is back to the Draft state. At the moment, the page header displayed would be the same as that in the Approved state.
Instead, we can include an additional trigger for a statechanged
event trigger to set a new value for the Page Header
metadata.
{trigger:statechanged|state=Approved}
{set-metadata:Page Header}
||Document Status|@pagestatus@|
||Author|@author@|
||Last content approval by|@Review>approvers@|
||Version|@version@|
{set-metadata}
{trigger}
Workflow markup
In this sample workflow, the workflow is applied in space mode, but it is filtered to documents with a dynamic header simple label.
{workflow:name=Trigger Configurable Header simple|label=dynamicheadersimple}
{description}
Provides a simple method of creating different headers (or footers or both) using triggers.
{description}
{pageheader:visibility=all}
{get-metadata:Page Header}
{pageheader}
{state:Draft|submit=In Progress}
{state}
{state:In Progress|approved=Approved}
{approval:Review|assignable=true}
{state}
{state:Approved|updated=Draft}
{state}
{trigger:pagecreated}
{set-metadata:Page Header}
{color:#FFFFFF}.{color}
{set-metadata}
{trigger}
{trigger:statechanged|state=In Progress}
{set-metadata:Page Header}
|| Document Status |{pagestatus}|
|| Page Author |@author@ |
|| Page Version |@version@ |
{set-metadata}
{trigger}
{trigger:statechanged|state=Approved}
{set-metadata:Page Header}
|| Document Status |{pagestatus}|
||Approved by|@Review>approvers@ |
|| Page Version |@version@ |
{set-metadata}
{trigger}
{trigger:statechanged|state=Draft}
{set-metadata:Page Header}
|| Document Status |{pagestatus}|
|| Last content approval by|@Review>approvers@ |
|| Page Author |@author@ |
|| Current Page Version |@version@ |
{set-metadata}
{trigger}
{workflow}
Related pages
Need support? Create a request with our support team.