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 will change each time the workflow state changes.
The page header content can be set as a metadata value and we can use a trigger to change the value of the metadata.
The content will display a different page header in each state.
The page header will change on each state transition.
- use a
set-metadatamacro for a
pagecreatedevent trigger to create and initialize the value for metadata named
- use the metadata
Page Headervalue as the content for the workflow
- use three triggers to change the metadata
Page Headervalue on different
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
This simply sets the value of the
Page Header metadata to be a white full-stop.
Page Header metadata is added to the workflow
pageheader using the
In workflow builder, this will be seen as an added page layout item for the workflow
When used as a space workflow, on the creation of a new page the content will have a page header added by the workflow that is simply a white full stop. The viewer will not see anything.
In the markup editor, the workflow will include the added
It is also easy to initialize a metadata value by using
initial=true in an event trigger such as a
statechanged event. This will set the metadata value on the first occurrence of the event. It's 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.
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
statechanged event trigger listening for the transition to the In Progress state.
- the trigger action is a
- this action macro sets a new value for 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 will display the following page header on the transition to the In Progress state from the initial Draft state in our workflow.
You will need to refresh the page after the transition for the page header to be updated.
Approved state page header
statechanged event trigger listening for the transition to the Approved state.
Page Header metadata value is a similar table of value references listing content and workflow information as used in the In Progress
statechanged trigger but this time 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 the Review approval had more than one assigned reviewer then the header will display all users who undertook 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.
In this sample workflow, the workflow is applied in space mode but application is filtered to content with a