Attachment events

Overview

Triggering events when attachments are created, updated or removed.In the following examples we show how to trigger a state transition when users add, update or remove attachments to a page or blog post in a specific workflow state.

Attachment created

If the workflow is in the "Approved" state, adding an attachment will trigger transition to the "In Progress" state.

{workflow:name=Attachment added}
   {state:In Progress}
   {state}
   {state:Approved}
   {state}
   {trigger:attachmentadded|state=Approved}
      {set-state:In Progress}
   {trigger}
{workflow}

Attachment updated

If the workflow is in the "Approved" state, updating an attachment (uploading a new version of existing attachment) will trigger transition to the "In Progress" state.

{workflow:name=Attachment updated}
   {state:In Progress}
   {state}
   {state:Approved}
   {state}
   {trigger:attachmentupdated|state=Approved}
      {set-state:In Progress}
   {trigger}
{workflow}

Attachment removed

If the workflow is in the "Approved" state, deleting an attachment will trigger transition to the "In Progress" state.

{workflow:name=Attachment added}
   {state:In Progress}
   {state}
   {state:Approved}
   {state}
   {trigger:attachmentremoved|state=Approved}
      {set-state:In Progress}
   {trigger}
{workflow}

Attachment version removed

If the workflow is in the "Approved" state, deleting an attachment version will trigger transition to the "In Progress" state.

{workflow:name=Attachment added}
   {state:In Progress}
   {state}
   {state:Approved}
   {state}
   {trigger:attachmentversionremoved|state=Approved}
      {set-state:In Progress}
   {trigger}
{workflow}

All of the above

If you want to transition on any of the events listed above, you can use the attachmentschanged (note the 's') event, like so:

{workflow:name=Any attachment event}
   {state:In Progress}
   {state}
   {state:Approved}
   {state}
   {trigger:attachmentschanged|state=Approved} {set-message:duration=PT1M}
         Attachment added, edited or deleted:
         || File    | @filename@   |
         || Size    | @size@ bytes |
         || Comment | @comment@    |
      {set-message}
      {set-state:In Progress}
   {trigger}
{workflow}

We've included a message to provide some details about the attachment; the details are derived from Event references which are available in all attachment-related events. Here's example output: