WorkflowInstance interface

You obtaining WorkflowInstance objects using the Instance management functions on the workflow Definition.

Always store WorkflowInstance objects in variables and function arguments called M, for consistency.

Interface

property title

The title (or name) of this workflow instance.

property url

The path to the page showing the user details of this workflow instance and the UI to interact with it.

property state

The current state of the workflow instance.

property target

Reserved.

property transitions

The Transitions object representing the currently available transitions.

property flags

A JavaScript Object containing all the currently set flags. Test a flag with M.flags.nameOfFlag.

property entities

Where you’re using the Entities workflow feature, the entities property is available as documented.

function selected(selector)

Return true if the instance is selected by the Selector.

function transition(transition, data)

Perform the named transition, with optional additional data to store in the Timeline.

function transitionUrl(transition, extraParameters)

Return the transition confirmation page URL for the given transition as a string. Optionally specify an extraParameters object to include any additional parameters required, eg: to specify the target.

function workflowService(name, arg1, arg2, …)

Call the registered workflow service called name. Workflow services are implemented with implementWorkflowService(). Further arguments are optional, and will be passed to the service function if specified.

This will return the first value returned by a registered service function.

An exception will be thrown if no service function is registered on this workflow for this name.

function workflowServiceMaybe(name, arg1, arg2, …)

Like workflowService(), except undefined is returned if no service function is registered on this workflow for this name.

function workflowServiceImplemented(name)

Returns true if there is at least one function registered to implement the workflow service name on this workflow.

function getTextMaybe(name, …)

The arguments are one or more text string names, specified in the definition’s text.

Return the first matching string, after interpolation, or undefined if a string can’t be found.

function hasRole(user, role)

Return true if the given user, as a SecurityPrincipal, has the given role.

function hasAnyRole(user, roles)

roles is an array of role names.

Returns true if the given user, as a SecurityPrincipal, has at least one of the roles.

function getActionableBy(actionableBy, target)

Returns the SecurityPrincipal representing the named actionableBy role.

target is reserved and should be omitted.

function addTimelineEntry(action, data)

Add a timeline entry with the given action and optional data. Use renderTimelineEntryDeferred() if they should be rendered in the timeline.

function timelineSelect()

Returns a DatabaseQuery set to query the TimelineRow objects for this workflow.

function getStateDefinition(state)

Returns the state definition for the given state. Use only as a last resort.

function recalculateFlags()

Recalculate the flags property. This is intended for use by plugins providing features which use modifyFlags(), and should be avoided in workflow implementations.

function sendEmail(emailDefinition)

Send the email defined. This is a generic Emails sending mechanism for workflows.

function sendNotification(notificationName)

Explicitly send a Notifications email.