Legacy Workflows Documentation

Looks like you followed an old link.  We have revamped our Comala Workflows Documentation, check it out here: Welcome to Workflows

This space is no longer being updated.

Triggers are actions executed in certain events. For example, sending an email notification when a page is approved, changing the state of a page when a label is added, or removing view restrictions when a page is published.

In this tutorial, we take the workflow we created in the previous tutorial and add email notifications and on-screen messages.

 

Adding "Under Review" when the page is submitted for review

We want to set the page message to Under review whenever the page is submitted for review.

We need to create a trigger for the statechanged event:

{workflow:name=Basic Workflow}
    ...
    {trigger:statechanged|state=Ready}
        {set-message:style=info}Under review{set-message}
    {trigger}
{workflow}

The message is set using the {set-message} macro.

Now, whenever we submit the page for review, the message shown is:

Setting a message when pages are created

This trigger works in a Space-wide workflow only as it handles the pagecreated. See how you can apply a workflow to all pages in a Space

We want to show a Draft message whenever a page is created. Create a trigger for the pagecreated event:

{workflow:name=Basic Workflow}
    ....
    {trigger:pagecreated}
        {set-message:style=note}Draft{set-message}
    {trigger}
    ...
{workflow}

Sending an email notification when a page is ready for final approval

Create a trigger for the statechanged event and use the {send-email} macro to send the notification:

{workflow:name=Basic Workflow}
    ...
    {trigger:statechanged|state=Reviewed}
        {send-email:user=@Editor in Chief@|subject=Page ready for final approval}
        The page @page@ has been approved by [~@user@] and is waiting
        for your final approval.
        {pageactivity}
        {send-email}
    {trigger}
{workflow}
  • Use the @Editor in Chief@ parameter
  • Use the (page) and{{ }}(user)value references to include links to the page and current user
  • Use the {pageactivity} to include the latest activity in the email body

Now, whenever the page's state is change to Reviewed, an email is sent to the Editor-in-Chief:

Adding a 'reject' email when Editor-in-Chief rejects the page

We want to send an email to the reviewer if a page is rejected by the Editor-in-Chief.

{workflow:name=Basic Workflow}
    ...
    {trigger:pagerejected|approval=Editor in Chief}
        {send-email:user=@Review>approver@|subject=Page rejected}
        The page @page@ has been rejected by [~@user@]
        {pageactivity}
        {send-email}
    {trigger}
    ...
{workflow}
  • We use the{{ }}(Review>approver) value reference to refer to the user who gave the Review approval.

Finalizing after the page is published, and manipulating labels

When the page's state changes to Published, we want to show a different message and add a label.

{workflow:name=Basic Workflow}
    ...
    {trigger:statechanged|state=Published}
        {set-message:style=tip}Published page!{set-message}
        {set-label:released}
    {trigger}
...
{workflow}

The {set-label} macro adds labels. We remove them using the {remove-label} macro.

To make sure nobody deletes the newly added label, use a trigger connected to the system 'labelremoved' event.

{workflow:name=Basic Workflow}
    ...
    {trigger:labelremoved|label=released|user=!@Editor in Chief@}
        {set-message:user|style=warning}You are not allowed to remove this label{set-message}
        {set-label:released}
    {trigger}
    ...
{workflow}

This labelremoved trigger is going to fire if the released label is removed by a user other that the one set in the Editor-in-Chief metadata value.

Our workflow is complete! All the transitions are recorded, and we can review the published version on a page:

Final Workflow

{workflow:name=Basic Workflow}
    {workflowparameter:Reviewers|description=Reviewers group|type=group}
        confluence-users
    {workflowparameter}
    {workflowparameter:Editor in Chief|description=User able to give final approval|type=user}
        @user@
    {workflowparameter}
    {state:Draft|submit=Ready}
    {state}
    {state:Ready|approved=Reviewed|rejected=Draft}
        {approval:Review|group=@Reviewers@}
    {state}
    {state:Reviewed|approved=Published|rejected=Ready}
        {approval:Editor in Chief|user=@Editor in Chief@}
    {state}
    {state:Published|final=true|updated=Ready}
    {state}
    {trigger:statechanged|state=Ready}
        {set-message:style=info}Under review{set-message}
    {trigger}
    {trigger:pagecreated}
        {set-message:style=note}Draft{set-message}
    {trigger}
    {trigger:statechanged|state=Reviewed}
        {send-email:user=@Editor in Chief@|subject=Page ready for final approval}
        The page @page@ has been approved by [~@user@] and is waiting
        for your final approval.
        {pageactivity}
        {send-email}
    {trigger}
    {trigger:pagerejected|approval=Editor in Chief}
        {send-email:user=@Review>approver@|subject=Page rejected}
        The page @page@ has been rejected by [~@user@]
        {pageactivity}
        {send-email}
    {trigger}
    {trigger:statechanged|state=Published}
        {set-message:style=tip}Published page!{set-message}
        {set-label:released}
    {trigger}
    {trigger:labelremoved|label=released|user=!@Editor in Chief@}
        {set-message:user|style=warning}You are not allowed to remove this label{set-message}
        {set-label:released}
    {trigger}
{workflow}
  • No labels