Versions Compared

Key

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

Table of Contents
maxLevel3
minLevel2
absoluteUrltrue
typeflat
separatorpipe

...

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

The workflow uses the following trigger actions

  • initialize a version value using 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 examples only work when the workflow is applied as a space workflow. The space workflow must be active to listen for the pagecreated event to initialize the metadata value.

Composite major-minor version content

Code Block
languagetext
themeRDark
{{workflow:name=Increment a Metadata Version 1|label=versionupdate}
    {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}
    {pageheader}
        ||Type|| Version||Version Number||
        |Page metadata|content-version value|@currentversion@|
        |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:currentversion}0.1{set-metadata}
    {trigger}
    {trigger:statechanged|state=Review}
        {increment-metadata:currentversion|increment=0.1}
    {trigger}
    {trigger:pageapproved|approval=Review}
        {increment-metadata:currentversion|increment=1.0}
    {trigger}
{workflow}

(star) 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.

(info) The get-metadata macro can be added to a page to retrieve and display the current value for metadata.

...

Trigger EventAction macroNotesConfluence and Metadata version displayed on content using get-metadata macro
pagecreatedset-metadata
  •  sets the metadata content-version and initializes the value to 0.1 on the creation of the page
  • only occurs if the workflow is applied in space mode on creation of a page

o

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

o


(star) Applying this workflow in ‘page mode’, the pagecreated trigger will never fire because the page is created before the workflow is applied. The metadata value would need to be initialized using a different event trigger.
statechangedincrement-metadata
  • increments the metadata content-version minor value by 1 on the transition to the Review state

o

pageapprovedincrement-metadata
  • increments the content-version major value by 1 each time the content is approved and transitions to Approved
  • minor value is reset to zero

o


Editing content in the Approved state

  • transitions the updated content to the Review state
  • the statechanged trigger 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

o

o

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

...

Code Block
languagetext
themeRDark
{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}

(star) Only works if this example workflow is applied as a space workflow.

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

...