WorkUnit interface

A JavaScript object implementing the WorkUnit interface represents a unit of work within the workflow system.

Construction

Create a new WorkUnit with O.work.create().

Load an existing WorkUnit given its ID with O.work.load().

Find existing WorkUnit objects with O.work.query().

Render a WorkUnit to HTML when requested by the hWorkUnitRender hook.

Usage

Set properties, then call save() commit the changes.

Interface

property id

The numeric ID of this work unit.

Accessing this property on a work unit which has not been saved with save() will throw an exception.

property workType

The type of work, as a String. This should in the form plugin_name:type to avoid clashing with other plugins.

property ref

The Ref of a store object to which this WorkUnit refers. This causes the work unit to be displayed on that object’s page.

property closed

Boolean. true if this work unit is closed.

property createdAt

Date. When this work unit was created.

property openedAt

Date. When the user is/was first expected to act on this work unit.

openedAt may be in the future, in which case, the task is not included in the actionable user’s task counts and is displayed in a “future tasks” tab in the listing. When the openedAt date is reached, it will appear in the count and normal task list.

property deadline

Date. A deadline for the next action for this work unit. The platform does not display this date to the user.

property closedAt

Date. When this work unit was closed.

property createdBy

Who created this work unit, read as a SecurityPrincipal.

This property can be set with a numeric ID or a SecurityPrincipal object.

property actionableBy

Which user or group can action and close this work unit, read as a SecurityPrincipal.

This property can be set with a numeric ID or a SecurityPrincipal object. Use the schema GROUP constants for specifying groups.

property closedBy

Which user or group can action and closed this work unit, read as a SecurityPrincipal, or null if it’s open.

This property can be set with a numeric ID or a SecurityPrincipal object.

property tags

An Object-like dictionary of short String to String key value pairs. Use for values that you will use in work unit queries and reporting, and the data property for all other information.

Ref objects will be automatically converted to a String, but otherwise, an exception will be raised if a non-String object is assigned to a key.

Work unit tags are indexed, and can be efficiently queried with a WorkUnitQuery tag() function.

Tags can be used for simple reporting, using the countByTags() function.

property data

JavaScript Object, which can only contain items which can be serialised to JSON. Use to store arbitrary data about the state of your workflow.

Note this is not a DataStore object, and the changes made are only saved when the save() function is called.

function isActionableBy(user)

Returns true if this work unit is actionable by user, either by being directly assigned to the work unit, or through group membership.

function close(closedBy)

Close the work unit. closedBy is either the ID of the closing user, or a SecurityPrincipal object.

You must call save() to commit this change.

function reopen()

Reopen the work unit.

You must call save() to commit this change.

function save()

Commit the changes to the work unit.

property isSaved

true if this work unit has been saved with save().

function deleteObject()

Delete this work unit.

If it’s useful to keep the work unit in the system as a record of a past action, consider closing the work unit and saving it instead of deleting it.

property visible

true if this work unit is visible in listings of work units.

Use with caution. This is intended to hide work units which are cancelled or otherwise abandoned, and will remove the work unit from most reporting functionality. You should probably set openedAt to a date in the future instead.

property autoVisible

true if the platform should apply sensible rules for setting the visible property.