Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

Table of Contents
maxLevel3
minLevel2
absoluteUrltrue
typeflat
separatorpipe
Excerpt
hiddentrue

Increment a composite version number for example, major.minor.patch metadata value each time a reviewer approves the content

...

Different events can be used to increment a composite version number.

The workflow uses the following trigger actions

  • initialize a version value using the set-metadata macro

  • increment the version value using the increment-metadata macro using different triggers for each element of a composite version number

You will need to refresh the page content to view changes in the metadata value if you use the get-metadata macro on the page to display the metadata value.

Info
iconfalse

(blue star) These These examples only work when the workflow is applied as a space workflow. The space workflow must be active to listen for the the pagecreated event  event to initialize the metadata value.

Composite major-minor version content

Code Block
languagetext
themeRDark
{{

Published version

Confluence versions change on each page update. You can use a metadata value and the increment-metadata macro to keep track of the number of times your document transitions to the final state - effectively using this metadata value as your published version value.

Code Block
{workflow:name=Increment a Metadata Version 1}
    {description}
        A simple approval workflow with use of increment-metadata macro to setidentify the major andpublished minor versions. The Majorsimple version is incremented on approval of content, minor
version on any update on the approved content
    {description}
    {pageheader}
        ||Type|| Version||Version Number||
        |Page metadata|content-versionPublishedversion value|@currentversion@@publishedversion@|
        |Confluence metadata|Confluence version value|@version@|
    {pageheader}
    {state:Review|approved=Approved|taskable=true}
        {approval:Review}
    {state}
    {state:Rejected|submit=Review|taskable=true}
    {state}
    {state:Approved|final=true|updated=Review|hideselection=true}
    {state}
    {trigger:pagecreated}
        {set-metadata:currentversionpublishedversion}0.1{set-metadata}
    {trigger}
    {trigger:statechanged|state=Reviewpageapproved|approval=Review}
        {increment-metadata:publishedversion}
    {trigger}
{workflow}

The workflow is added and enabled as a space workflow in the space tools Document Management dashboard for the space.

On creating a page in the space, the value for the metadata publishedversion is set as”0”.

...

Info

The metadata publishedversion value is set using the set-metadata macro.

In the workflow page header added to the page as a table the publishedversion metadata value is retrieved by the workflow using @publishedversion@.

The page has not yet been approved as there has been no transition to the final state - the Approved state in our workflow.

Each page edit updates the Confluence version.

...

Info

These updates do not change the publishedversion metadata value.

Approving the page in the Review state, transitions the workflow on the page to the Approved state.

The workflow trigger listening for this page approval event increments the value of the metadata publishedversion.

...

Editing the page in the Approved state transitions the workflow on the page back to the Review draft state.

...

Each subsequent approval of the page and transition to the Approved state increments the publishedversion value.

...

Info

Choosing (view “Approved”) when in the draft Review state displays a Confluence version from Page History.

The metadata value is linked to a page not a Confluence page version so when viewing a previous page version this will show the current metadata value. This is NOT the metadata value when the content was published.

Composite major-minor version content

Code Block
languagetext
{workflow:name=Increment a Metadata Version major minor}
    {description}
        A simple approval workflow with use of increment-metadata macro to set the major and minor versions. Major version incremented on approval of content, minor version on any update on the approved content
    {description}
    {state:Review|approved=Approved|taskable=true}
        {approval:Review}
    {state}
    {state:Rejected|submit=Review|taskable=true}
    {state}
    {state:Approved|final=true|updated=Review|hideselection=true}
    {state}
    {trigger:pagecreated}
        {set-metadata:currentversion}0.0{set-metadata}
    {trigger}
    {trigger:pageupdated}
        {increment-metadata:currentversion|increment=0.1}
    {trigger}
    {trigger:pageapproved|approval=Review}
        {increment-metadata:currentversion|increment=1.0}
    {trigger}
{workflow}

...

In our example, applying the space workflow to existing pages will not initialize

...

the currentversion metadata value and subsequent use of

...

the currentversion

...

 metadata in

...

the increment-metadata

...

 macro will not work.

...

Tip

Instead of using the pageheader macro in the workflow, the get-metadata macro can be added to a page to retrieve and display the current value for metadata.

...

Here's how each trigger action works.

Trigger Event

Action macro

Notes

Confluence and Metadata version displayed on content using get-metadata macro

pagecreated

set-metadata

  •  sets the metadata 

content-version
  • currentversion and initializes the value to 0.

1
  • 0 on the creation of the page

This only occurs on the creation of a page if the workflow is applied in space mode

on creation of a page

.

Image Added

o

Image Removed

Editing content in the Initial state updates the Confluence version value but not our metadata value.

oImage Removed

(star) 

Note

Applying this workflow in ‘page mode’,

the 

the pagecreated

 trigger

 trigger will never fire because the page

is created before the

is created before the workflow is applied.

The

To use within a page workflow, the metadata value would need to be initialized using a different event trigger.

statechanged

pageupdated

increment-metadata

  • increments the

metadata content-version
  • currentversion minor value by 1

on the transition to the Review stateoImage Removed
  • each time the page is updated

  • major value is not changed

Image Added

Editing the page updates both the

  • Confluence version value

  • metadata minor value of the currentversion metadata

    • increments the minor value by 1

pageapproved

increment-metadata

  • increments the

content-version
  • currentversion major value by 1 each time the content is approved and transitions to Approved

  • minor value is reset to zero

oImage Removed

Editing content
Image Added

On approving the page and transitioning to the Approved state the pageapproved trigger

  • increments by 1 the major value of the currentversion metadata

  • sets the minor value to 0 of the currentversion metadata

pageupdated

increment-metadata

  • increments the currentversion minor value by 1 each time the content is updated

  • major value is not changed

Image Added

Editing the page in the Approved state

  • transitions the updated

content
  • page to the Review state

  • updates the

statechanged trigger
  • Confluence version

  • increments the minor value

of the content-version metadata

An individual reviewer rejection decision on its own does not impact the metadata content-version value. 

The metadata value is linked to a page not a Confluence page version so when viewing a previous page version this will show the current metadata value.

For example, viewing the final Approved state content whilst content is in draft would display the current metadata value NOT the metadata value when the content was published.

Content in draft stateContent in published state

oImage Removed

oImage Removed

Edit the Approved state, content updates and transitions to draft state Review.

The displayed metadata would be

  • current Confluence version (Confluence metadata)
  • incremented page metadata content version value (content-version value)

Content in Approved state prior to editing. The get-metadata macros on the page retrieve and display

  • previous Confluence version (Confluence metadata)
  • but the current page metadata content-version value that was incremented on the last transition to the draft state Review
    • by 1 of the currentversion metadata

    pageupdated

    increment-metadata

    • increments the currentversion minor value by 1 each time the content is updated

    • major value is not changed

    Image Added

    Editing the page in the draft Review state, with a previously approved version

    • updates the Confluence version

    • increments the minor value by 1 of the currentversion metadata

    Info

    The minor version value in this example is the number of page updates since the last approved version.

    pageapproved

    increment-metadata

    • increments the currentversion major value by 1 each time the content is approved and transitions to Approved

    • minor value is reset to zero

    Image Added

    On approving the page and transitioning to the Approved state the pageapproved trigger

    • increments by 1 the major value of the currentversion metadata

    • sets the minor value to 0 of the currentversion metadata

    Info

    The major version value in this example is the number of times the page has been approved and published.

    In this example, a page in the Approved state always transitions to the Review state when the page is updated. This means in the example

    • the published version will always be a major version with no minor version (for example 2.0; 3.0; 4.0 etc)

    • the minor versions will only be displayed for the page in a draft state (for example (2.1; 2.2; 2.3 etc).

    An individual reviewer rejection decision on its own does not impact the metadata currentversion value. 

    Manage composite major-minor-patch version of the content

    ...

    This second example below  uses the increment-metadata macro to support the custom versioning of a page using a composite numeric metadata value.

    The elements of the composite version are incremented when different specific events occur.

    Code Block
    languagetextthemeRDark
    {workflow:name=Composite Increment Metadata}
        {state:Draft|submit=Review}
        {state}
        {state:Review|approved=Approved}
            {approval:Review|assignable=true}
        {state}
        {state:Approved|final=true|submit=Draft}
        {state}
        {trigger:pagecreated}
            {set-metadata:comp-version}
                0.0.1
            {set-metadata}
        {trigger}
    	{trigger:pageupdated}
            {increment-metadata:comp-version|increment=0.0.1}
        {trigger}   
        {trigger:statechanged|state=Review}
            {increment-metadata:comp-version|increment=0.1.0}
        {trigger}   
        {trigger:statechanged|state=Approved}
            {increment-metadata:comp-version|increment=1.0.0}
        {trigger}
    {workflow}

    ...

    Note

    Only works if this example workflow is applied as a space workflow as the metadata value is initialized on the pagecreated trigger.

    The metadata name and initial value are set on the creation of the page using a trigger macro and the set-metadata action macro.

    {set-metadata:comp-version}0.0.1{set-metadata}

    A version change will occur:

    • for every page edit (a PATCH version change)

    • on a state change to the Review state(a MINOR version change).

    • on a state change to the Approved state (a MAJOR version change).

    Metadata value initialization

    Page creation creates the metadata comp-version and sets the initial value as 0.0.1

    {set-metadata:comp-version} 0.0.1 {set-metadata}

    oImage Modified

    Minor element value update

    A state change to the Review state will update the second numeric element (MINOR element)of the version by 1.

    The workflow uses a trigger macro on the statechanged event for state=Review and theincrement-metadata action macro.

    {increment-metadata:comp-version|increment=0.1.0}

    oImage Modified

    This also resets the final numeric element to zero e.g. a version value 2.1.3 will change to 2.2.0.

    Major element value update

    A state change to the Approved state will update the first numeric element (MAJOR element) of the version by 1. 

    The workflow uses a trigger macro on the statechanged event for state=Approved and the increment-metadata action macro.

    {increment-metadata:comp-version|increment=1.0.0}

    oImage Modified

    This also resets the second numeric element and the final numeric element to zero e.g. the version 2.2.5 will change to 3.0.0.

    ...

    A page edit will increase the final numeric element (PATCH element)of the version using a trigger macro on the pageupdated event and the increment-metadata action macro.

    {increment-metadata:comp-version|increment=0.0.1}

    oImage Modified

    The final numeric element of the version will increment by 1 for a page edit in any of the workflow states.

    ...

    Related examples