---
title: "Dynamic page header using a metadata value and triggers"
canonical: "https://support.appfire.com/space/CDML/649693344/Dynamic%20page%20header%20using%20a%20metadata%20value%20and%20triggers"
format: markdown
---
> Macro (aura-html)


> Macro (excerpt)
> 
> Use a trigger to display a different page header for each state in the workflow. Page header content is set as a metadata value.

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

![image](media://f37555cd-d118-43d2-8085-932858f1b40a)

  
The workflow has been configured to display a different page header in each workflow state.

![image](media://9bd83880-0f1c-413d-88e1-5ff3ffa0e49c)

  
The page header changes on each state transition.

![image](media://f2203a7e-5c91-412f-8634-ff53192745ea)

This example utilizes:

- A [set-metadata macro](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650251172) for a `pagecreated` event trigger to create and initialize the value for metadata named `Page Header`
- A workflow [pageheader macro](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650348817) whose value is the metadata `Page Header`** **value
- Three [trigger macros](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649859133)  to change the metadata `Page Header`** **value on different [event trigger transitions](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650218590)

## 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](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649826804).

You add the macro to the workflow page header in the workflow builder:

![image](media://2112749b-197b-49b3-9304-a7a6e5371759)

In workflow builder, this is displayed as a **Page Layout** item for the workflow.

![image](media://48ec1e0b-a86a-466c-9c74-4496291aa075)

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.

![image](media://70102d1d-4b9b-499c-be82-2cea9126aea6)

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` 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 displays the following page header when transitioning to the **In Progress** state from the initial **Draft** state in our workflow.

![image](media://1523889c-aa61-4e67-b63b-32f7ea7c8eb6)

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](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649728358):

- `@Review>approvers@ `to retrieve the users who undertook the approved decision as part of the **Review** approval in the** In Progress** state

![image](media://31392dae-c02d-4d40-8bbc-7aebab2c8fa2)

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

- [https://appfire.atlassian.net/wiki/spaces/CDML/pages/649859133](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649859133)
- [https://appfire.atlassian.net/wiki/spaces/CDML/pages/650218590](https://appfire.atlassian.net/wiki/spaces/CDML/pages/650218590)
- [https://appfire.atlassian.net/wiki/spaces/CDML/pages/649925583](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649925583)
- [https://appfire.atlassian.net/wiki/spaces/CDML/pages/649693867](https://appfire.atlassian.net/wiki/spaces/CDML/pages/649693867)