Workflow Triggers

Smartsite 7.1 - ...

The CmsServer included within Smartsite 7.1 has a new feauture, which allows you to execute workflow triggers. This article describes how this can be achieved.

(Legacy) workflow

When editing an item within the Smartsite 7.1 Manager, the user is presented a workflow state dropdown to choose a state from (e.g. "Busy, "Ready for approval", "Activate"). This dropdown represents the states available within the default (legacy) workflow, which has been configured for the contenttype of the item. Usually, this is one of the three by default available workflows:

  • Basic Workflow (WF_DEFAULT)
  • Complete Workflow (WF_COMPLETE)
  • Automatic Workflow (WF_AUTOMATIC)

Then, when the user saves the item specifying one of the states, the CmsServer executes the workflow, transitioning the workflow from one state to another (as defined within the default (legacy) workflow), until the specified state has been reached. For each of these state transitions, a workflow trigger can be implemented and called.

Specify Workflow Triggers

The contenttype Workflow Definition has been adjusted and now includes the field Triggers, which can be used to specify one or more workflow triggers for a specific workflow definition.

The example below shows an example.

<triggers xmlns="http://smartsite.nl/namespaces/workflowtriggers/1.0">
 <trigger url="http://localhost/Def/workflow-trigger-example.html" tostate="wf_complete_publish" />
 <trigger type="Smartsite.Cms.Workflow.WorkflowTriggerTest, CmsServer" async="true">
  <parameters>
   <parameter name="key1">value 1</parameter>
   <parameter name="key2">value 2</parameter>
  </parameters>
 </trigger>
</triggers>

There are two types of workflow triggers that can be implemented/called:

  1. Url-type workflow trigger: the url attribute is used to execute an http webrequest, using the querystring to pass the workflow-related parameters.
  2. Object-type workflow trigger: the type attribute is used to specify an object, which will be invoked. This object must implement the IWorkflowTrigger interface and it will be invoked on the OnAfterStatusChange method, passing in the workflow-related parameters using the WorkflowTriggerSettings param.

The table below describes the workflow-related parameters that will be available.

Parameter Url-type workflow trigger Object-type workflow trigger
The item number The itemnumber querystring parameter WorkflowTriggerSettings.ItemNumber parameter
The from state The fromstate querystring parameter WorkflowTriggerSettings.FromState parameter
The to state The tostate querystring parameter WorkflowTriggerSettings.ToState parameter
The target state The targetstate querystring parameter WorkflowTriggerSettings.TargetState parameter
The user id The userid querystring parameter WorkflowTriggerSettings.UserNumber parameter
The assign to group (new in Smartsite 8.0) The assigntogroup querystring parameter WorkflowTriggerSettings.AssignToGroup parameter
The assign to user (new in Smartsite 8.0) The assigntouser querystring parameter WorkflowTriggerSettings.AssignToUser parameter

The target state represents the state which was selected when saving an item. The to and from state(s) represent the state transitions in between, when the different workflow steps are executed for the item. In most cases, the to state is the one to use.

The user id represents the user (id) which triggered the workflow, in other words (in most cases) the user that saved the item.

The assign to group and assign to user parameters will be available when the item has been assigned to a specific user and/or group. These two are available as of Smartsite 8.0.

Shared parameters

Besides the url and type attributes to specify a workflow trigger, there are several parameters available to determine when a workflow trigger must be invoked. These parameters are set by specifying an attribute on the trigger element with the same name. The available parameters are described within the table below.

Parameter Default Description
contenttypes * A comma-separared list of contenttype codes for which the trigger must be invoked, e.g. "WP,NWS,CWP".
If the item's contenttype does not match one of the contenttype codes specified, the trigger will not be invoked.
By default (="*"), no contenttype filtering takes place.
enabled true Whether or not the trigger is enabled. When set to false, the trigger will not be invoked.
fromstate * A comma-separated list of fromstate(s) for which the trigger must be invoked, e.g. "wf_complete_disapprove".
If the "from" state does not match one of the fromstate(s) specified, the trigger will not be invoked.
By default (="*"), no fromstate filtering takes place.
tostate * A comma-separated list of tostate(s) for which the trigger must be invoked, e.g. "wf_complete_publish".
If the "to" state does not match one of the tostate(s) specified, the trigger will not be invoked.
By default (="*"), no tostate filtering takes place.
targetstate * A comma-separated list of targetstate(s) for which the trigger must be invoked, e.g. "Assigned".
If the "target" state does not match one of the targetstate(s) specified, the trigger will not be invoked.
By default (="*"), no targetstate filtering takes place.
async true Whether or not the workflow trigger must be invoked asynchronously.

Url-type workflow trigger parameters

There are several additional parameters available for an url-type workflow trigger, which will be needed when the specified url requires authentication. These are described in the table below.

Parameter Description
username The username for authentication.
password The password for authentication.
authenticationtype The authentication type (Basic or NTLM).
"Basic" is the default, use "NTLM" when the specified url uses Windows authentication.

Notice that, when the site the url attribute points to uses (Smartsite) forms authentication, you need to configure the Smartsite BasicAuthentication Module to bypass the forms-based authentication redirect which normally takes place and include the "hid=nofba" setting on the querystring of the specified url to trigger this functionality. The article Forms-based authentication suppression describes this in more detail.

Object-type workflow trigger parameters

On an object-type workflow trigger, an arbitrary number of parameters can be specified, using the notation as shown in the example above. These key-value pairs will be available within the WorkflowTriggerSettings.Parameters dictionary.

Topics