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.


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


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 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.