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 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.


We will

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 using the get-metadata macro.



 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 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 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.

{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 macro
  • this 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 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

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 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.

{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 application is filtered to content with a dynamicheadersimple 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}


See also

Workflow Authoring Guide