Skip to main content
Browse Documentation

Workflow

Created by Scott Yearsley, last updated 20 Feb 2018

The Workflow object is readonly and contains information about the current workflow state for the entry.Workflow. It also includes details about the previous state transition which resulted in the entry being in the current state along with a list of allowed events that can be invoked by the current user based on their permissions.

Properties

Name Type Description
Id string The workflow id that controls the entry life-cycle
State string The id of the state that the entry is currently in
AllowedEvents string[] The events that can be invoked by the user based on permissions and the current entry state
Transition WorkflowTransition Details about the previous workflow transition

Methods

Invoke

Invokes a named workflow event.

Syntax

public void Invoke(string event)
{
}

Parameters

event

Type: string
The id of the workflow event to invoked, e.g. submit

Return value

Type: void

Example

// Submit the entry for approval.
entry.Workflow.Invoke("submit");

InvokeAsync

Invokes a named workflow event asynchronously.

Syntax

public async Task InvokeAsync(string message)
{
}

Parameters

event

Type: string
The id of the workflow event to invoked, e.g. submit

Return value

Type: Task

Example

// Submit the entry for approval.
await entry.Workflow.InvokeAsync("submit");

Invoke with Dictionary

Invokes a named workflow event with an optional Dictionary<string, object> data parameter.

Syntax

public void Invoke(string event, Dictionary<string, object> data)
{
}

Parameters

event

Type: string
The id of the workflow event to invoked, e.g. submit

data

Type: Dictionary<string, object>
A dictionary of named data items to include as part of the event invocation

Return value

Type: void

Remarks

The values in the data can only be simple types, i.e. string, int, decimal, datetime, bool. If a complex object type is passed then an ArgumentException will be thrown.

Example

// Submit the entry for approval.
entry.Workflow.Invoke("submit", new Dictionary<string, object>
{
    { "message", "Added additional photos to the intro" }
});

InvokeAsync with Dictionary

Invokes a named workflow event asynchronously with an optional Dictionary<string, object> data parameter.

Syntax

public async Task InvokeAsync(string message)
{
}

Parameters

event

Type: string
The id of the workflow event to invoked, e.g. submit

data

Type: Dictionary<string, object>
A dictionary of named data items to include as part of the event invocation

Return value

Type: Task

Remarks

The values in the data can only be simple types, i.e. string, int, decimal, datetime, bool. If a complex object type is passed then an ArgumentException will be thrown.

Example

// Submit the entry for approval.
await entry.Workflow.InvokeAsync("submit", 
    new Dictionary<string, object>
    {
        { "message", "Added additional photos to the intro" }
    }
);

Invoke with anonymous object

Invokes a named workflow event with an optional anonymous object data parameter.

Syntax

public void Invoke(string event, object data)
{
}

Parameters

event

Type: string
The id of the workflow event to invoked, e.g. submit

data

Type: object
An anonymous object to include as part of the event invocation

Return value

Type: void

Remarks

The values in the data can only be simple types, i.e. string, int, decimal, datetime, bool. If a complex object type is passed then an ArgumentException will be thrown.

Example

// Submit the entry for approval.
entry.Workflow.Invoke("submit",
    new
    {
        Message = "Added additional photos to the intro"
    };
);

InvokeAsync with anonymous object

Invokes a named workflow event asynchronously with an optional anonymous object data parameter.

Syntax

public async Task InvokeAsync(string message)
{
}

Parameters

event

Type: string
The id of the workflow event to invoked, e.g. submit

data

Type: Dictionary<string, object>
An object to include as part of the event invocation

Return value

Type: Task

Remarks

The values in the data can only be simple types, i.e. string, int, decimal, datetime, bool. If a complex object type is passed then an ArgumentException will be thrown.

Example

// Submit the entry for approval.
await entry.Workflow.InvokeAsync("submit",
    new
    {
        Message = "Added additional photos to the intro"
    };
);