Versions Compared

Key

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

Table of Contents
maxLevel3
minLevel2
absoluteUrltrue
typeflat
separatorpipe

Excerpt
hiddentrue

Use the {increment-metadata} macro to increment major.minor.patch metadata value for a single approval using three triggers.

Overview

Different events can be used to increment a composite version number using the increment-metadata macro.

You can add a condition to a trigger to increment one element of a composite version.

In this approval workflow the approver in the Review state chooses the element of the composite version update being approved.

  • the composite version number is set as a metadata value of 1.0.0 for @current-version@ on the page creation
  • a workflow parameter @Update type@ is created Update type is created as a list type parameter with a choice of three values, one for each composite version element - Major, Minor, Patch
  • the content review approve decision requires the setting of the @Update type@  workflow Update type  workflow parameter value prior to the approved transition
  • the required parameter value is one of for the Approved transition is selected from the list options of a Major update, Minor update or Patching Patch update


  • the choice of Major, Minor or Patch parameter value acts as a condition for one of three triggers to update the appropriate metadata version component of @current-version@ using the increment-metadata macro.

Use of triggers

The workflow uses the following trigger actions

  • a pagecreated event trigger initializes a version value using the set-metadata macro
  • three pageapproved event triggers increment the component version value using the increment-metadata macro. Each trigger updates a different element of the composite metadata version number
  • statechanged event trigger clears any existing value for the @Update type@ workflow parameter on a transition to the Review state

Each of the three pageapproved event triggers listen for the approval decision for the Approved content review in the Review state. But each trigger has a condition based on the type of version update set by the approver.

  • the condition is the value of the workflow parameter Update type=Major update or =Minor update or =Patching update.

Using set-metadata macros, values for the following metadata are also updated in each of these three triggers.

  • @last-approver@
  • @last-date@
  • @current-type@

These are displayed on the content using the pageheader macro.

You may need to refresh the page content to view changes in the displayed metadata values.

Workflow parameter value trigger condition

Major, Minor and Patch are workflow parameter values set as a list option choice for the workflow parameter @Update type@.

...

Once confirmed the approved transition occurs.

Composite major-minor-patch version workflow

Code Block
languagetext
themeRDark
{workflow:name=Increment a Metadata Version conditional|label=versiontest}
    {description}
    A simple approval workflow with use of increment-metadata macro to set the version of
    of approved contentand increment the version on the approval transition.
    {description}
    {pageheader}
         |Owner|@creator@|
         |Version|@current-version@|
         |Latest update|@current-type@ on @last-date@ by @last-approver@|
    {pageheader}
    {workflowparameter:Update type|description=Please, select the update type: Major (x.0.0), Minor (0.x.0), Patch (0.0.x)|type=list|options=Major,Minor,Patch|edit=true}
    {workflowparameter}
    {state:Review|approved=Approved|rejected=Rejected|taskable=true}
         {approval:Please review the content}
    {state}
    {state:Rejected|submit=Review|taskable=true|colour=#FF5630}
    {state}
    {state:Approved|final=true|updated=Review|hideselection=true|requiredparams=Update type}
   {state}
   {trigger:pagecreated}
       {set-metadata:current-version}1.0.0{set-metadata}
   {trigger}
   {trigger:statechanged|state=Review}
       {set-metadata:Update type}{set-metadata}
   {trigger}
   {trigger:pageapproved|approval=Please review the content|@Update type@=Major}
       {increment-metadata:current-version|increment=1.0.0}
       {set-metadata:current-type}Major update{set-metadata}
       {set-metadata:last-date}@date@{set-metadata}
       {set-metadata:last-approver}@user@{set-metadata}
  {trigger}
  {trigger:pageapproved|approval=Please review the content|@Update type@=Minor}
       {increment-metadata:current-version|increment=0.1.0}
       {set-metadata:current-type}Minor update{set-metadata}
       {set-metadata:last-date}@date@{set-metadata}
       {set-metadata:last-approver}@user@{set-metadata}
  {trigger}
  {trigger:pageapproved|approval=Please review the content|@Update type@=Patch}
      {increment-metadata:current-version|increment=0.0.1}
      {set-metadata:current-type}Patching update{set-metadata}
      {set-metadata:last-date}@date@{set-metadata}
      {set-metadata:last-approver}@user@{set-metadata}
   {trigger}
{workflow}


...

Here's how each trigger action works

Trigger EventAction macroNotes
pagecreated{set-metadata}
  •  sets the metadata current-version and initializes the value to 1.0.0 on the creation of the page
  • metadata displayed on the page using {pageheader} macro
  • only occurs if the workflow is applied in space mode

oImage Modified

pageapproved|...@Update
-
type@=Major

{increment-metadata}

{set-metadata}

  • increments the composite current-version major value by 1 each time the content is approved, the approver sets the required parameter value to Major update and transitions to Approved
  • minor and patch value are reset to zero
  • three separate set-metadata action macros update values for each of the following metadata
    • @last-approver@
    • @last-date@
    • @current-type@

oImage Modified

oImage Modified


pageapproved|...@Update
-
type@=Minor

{increment-metadata}

{set-metadata}

  • increments the composite current-version minor value by 1 each time the content is approved, the approver sets the required parameter value to Minor update and transitions to Approved
  • patch value is reset to zero
  • three separate set-metadata action macros update values for each of the following metadata
    • @last-approver@
    • @last-date@
    • @current-type@

oImage Modified

oImage Modified

pageapproved|...@Update
-
type@=Patch

{increment-metadata}

{set-metadata}

  • increments the composite current-version patch value by 1 each time the content is approved, the approver sets the required parameter value to Patching update and transitions to Approved
  • three separate set-metadata action macros update values for each of the following metadata
    • @last-approver@
    • @last-date@
    • @current-type@

oImage Modified

oImage Modified

statechanged|state=Review{set-metadata}
  • clears the value of the workflow parameter Update type on transition to the Review state
  • the {set-metadata :Update type}{set-metadata} action macro with an  empty body clears any value for the workflow parameter. This means that before the Approved transition can occur the user will be required to set the Update type parameter value


Only the approved transition to the Approved state will update the metadata version in this example.

(blue star) When using the increment-metadata macro, incrementing the major version element will reset the minor and patch elements to zero. Incrementing the minor element resets the patch element to zero.