Obsolete Pages{{Obsolete}}
The official documentation is at: http://docs.alfresco.com
The purpose of the Workflow JavaScript API is to allow access to Alfresco advanced workflows from within JavaScript. The API supports EMCA Script 1.6 compatible JavaScript. Through this API workflow definitions, instances, paths, tasks and transitions can be accessed and managed.
The Workflow JavaScript API may be used to do any of the the following:
The object model for this API is similar to that of the Advanced Workflow Java API. The relationships between the various types used in this API are the same as the relationships between the various classes used in the Advanced Workflow API. Each class in the Workflow JavaScript API mirrors a class in the Advanced Workflow API, however the JavaScript classes are somewhat simpler, making them more easily accessible from JavaScript. All the JavaScript classes implement the Serializable interface allowing them to be stored in Scriptable objects.
Note that all methods specified in this document use the Java method names.
The Workflow Manager is the entry point to the Workflow JavaScript API. It is the only object in the this API that is exposed to the root scripting scope. In the root scripting scope, the WorkflowManager object is identified as 'workflow'.
Name | Params | ReturnType | Description |
---|---|---|---|
getAllDefinitions | A JavaScript array containing JscriptWorkflowDefinitions. | Returns all versions of all deployed workflow definitions. Note that this method will return old versions of workflow definitions as well as the most current version. If you only want the current versions of all deployed workflow definitions then use 'getLatestDefinitions(). | |
getAssignedTasks | A JavaScript array containing JscriptWorkflowTasks. | Returns all tasks that are assigned to the current user and that are currently in-progress. | |
getCompletedTasks | A JavaScript array containing JscriptWorkflowTasks. | Returns all tasks that are assigned to the current user and that are completed. | |
getDefinition | String id: A workflow definition id. | A JscriptWorkflowDefinition. | Returns the workflow definition with the given Id. If no workflow definition with the given Id exists then this method returns null. |
getDefinitionByName | String name: The name of the workflow definition to be returned. | A JscriptWorkflowDefinition. | Returns the workflow definition with the given name. If no workflow definition with the given name exists then this method returns null. |
getInstance | String workflowInstanceId: The id of the workflow instance to be returned. | A JscriptWorkflowInstance. | Returns the workflow instance with the given Id. If no workflow instance with the given Id exists then this method returns null. |
getLatestDefinitions | A JavaScript array containing JscriptWorkflowDefinitions. | Returns the latest version of all deployed workflow definitions. Note that this method will not return old versions of workflow definitions, only the most current version. If you want all versions of all deployed workflow definitions then use 'getDefinitions(). | |
getPooledTasks | String authority: A String specifying the id of the authority. | A JavaScript array containing JscriptWorkflowTasks. | Returns the pooled workflow task instances available to the given authority. A pooled task may be assigned to a group of users and then one of those users may take ownership of the task and progress it. |
getTask | String id: The id of the workflow task instance to be returned. | A JscriptWorkflowTask. | Returns the workflow task instance with the given Id. If no workflow task instance with the given Id exists then this method returns null. This method is identical to 'getTaskById(String id)'. |
getTaskById | String id: The id of the workflow task instance to be returned. | A JscriptWorkflowTask. | Returns the workflow task instance with the given Id. If no workflow task instance with the given Id exists then this method returns null. This method is identical to 'getTask(String id)'. |
Name | Params | ReturnType | Description |
---|---|---|---|
createPackage | A ScriptNode. | Creates a package, a container node that can be used to store content associated with a workflow instance. Returns a reference to the created container. |
The workflow definition is the type (or template) of a workflow process. A workflow process definition relates to a workflow instance in the same way that a Java class definition relates to an instance of that class. The workflow definition may be used to create (start) new workflow instances of that type. It may also be used to find all currently active instances of that type. A workflow definition has several properties, including an Id, Name, Version, Title and Description.
Name | Params | ReturnType | Description | |
---|---|---|---|---|
getActiveInstances | A JavaScript array containing JScriptWorkflowInstances. | Returns all active workflow instances for this workflow definition | ||
getDescription | A String description. | Returns the description for this workflow definition. | ||
getId | A String id. | Returns the id for this workflow definition. | ||
getName | A String name. | Returns the name for this workflow definition. | ||
getTitle | A String title. | Returns the title for this workflow definition. | ||
getVersion | A String Version. | Returns the version number for this workflow definition. |
Name | Params | ReturnType | Description |
---|---|---|---|
startWorkflow | Object properties: A set of workflow properties. If properties is not of type ScriptableObject it will be ignored. | A JScriptWorkflowPath. | Creates and starts a new workflow instance of the workflow definition's type. Returns the workflow path for the created instance. Note this method does not set a package container. |
startWorkflow | Object properties: A set of workflow properties. If properties is not of type ScriptableObject it will be ignored. ScriptNode package: | A JScriptWorkflowPath. | Creates and starts a new workflow instance of the workflow definition's type. Returns the workflow path for the created instance. |
The workflow instance holds various data about a workflow, such as when it started, when it is due, it's current state etc. A workflow instance may be cancelled (made inactive) or deleted.
Name | Params | ReturnType | Description |
---|---|---|---|
getDescription | A String description. | Returns the description for this workflow instance. | |
getEndDate | A Scriptable representation of a date. | Returns the date when this workflow instance ended. | |
getId | A String id. | Returns the id for this workflow instance. | |
getPaths | A JavaScript array containing JScriptWorkflowPaths. | Returns all the paths associated with this workflow instance. | |
getStartDate | A Scriptable representation of a date. | Returns the date when this workflow instance was started. | |
isActive | A boolean. | Returns true if the workflow instance is in-progress, otherwise returns false. |
Name | Params | ReturnType | Description |
---|---|---|---|
cancel | Void | Cancels the workflow instance, ending it. | |
delete | Void | Deletes the workflow instance, ending it. |
Note: Because 'delete' is a reserved word in JavaScript, you must call it using bracket notation, like this:someWfInstance['delete']();
A workflow node is a single point in the workflow process. Some workflow nodes are task nodes, these nodes have a task associated with them which must be completed before the workflow can transition to the next node.
Name | Params | ReturnType | Description |
---|---|---|---|
getDescription | A String description. | Returns the description for this workflow node. | |
getName | A String name. | Returns the name for this workflow node. | |
getTitle | A String title. | Returns the title for this workflow node. | |
getTransitions | A JavaScript array containing JscriptWorkflowTransitions. | Returns the list of transitions that are available for this node. | |
isTaskNode | A boolean. | Returns true if this node is a Task node, otherwise returns false. |
The workflow path represents the current state (position) of a workflow instance. The path stores state about the current position in the workflow as well as the path taken through the workflow to reach this point. An in-progress workflow may have multiple workflow paths if the process contains any forking nodes. The workflow path can be signalled to transition to the next node in the process.
Name | Params | ReturnType | Description |
---|---|---|---|
getId | A String id. | Returns the id for this workflow path. | |
getInstance | A JScriptWorkflowInstance. | Returns the workflow instance to which this workflow path belongs. | |
getNode | A JScriptNode. | Returns the current node (position) of the workflow path. | |
getTasks | A JavaScript array containing JscriptWorkflowTasks. | Returns all the task instances associated with this workflow path. | |
isActive | A boolean. | Returns true if this workflow path is in-progress, otherwise returns false. |
Name | Params | ReturnType | Description |
---|---|---|---|
signal | String transitionId: The id of the transition to be taken by the workflow path. | A JScriptWorkflowPath. | Signals the workflow path to transition to the next node. The specific transition used is specified by the transitionId parameter. The workflow path returned is the newly transitioned path. |
This class represents a specific instance of a workflow task as opposed to a workflow task definition (the type of a task). A workflow task instance is a representation of a user action, usually something which cannot be automated in the workflow. Task instances can be associated with workflow nodes within the process definition. When the workflow path reaches a node with an associated task it will not progress until the task has been completed and a transition is signalled by the user. Some typical examples of where tasks might be used include reviewing/approving documents, editing/appending documents, marking exam papers, etc.
A workflow task instance can be signalled with a transition, causing the workflow path to progress to the next node with the specified transition.
Name | Params | ReturnType | Description |
---|---|---|---|
getDescription | A String description | Returns the description for the workflow task instance. | |
getId | A String id | Returns the id for the workflow task instance. | |
getName | A String name | Returns the name for the workflow task instance. | |
getPackageResources | A JavaScript array containing ScriptNodes. | Returns the content stored in the package container associated with this workflow task instance. | |
getProperties | A ScriptableQNameMap<String Serializable> | Returns a map containing all the properties associated with this task instance. | |
getTitle | A String title | Returns the title for the workflow task instance. | |
getTransitions | A ScriptableHashMap<String, String> | Returns a map containing all the transition ids (the map keys) and transition titles (the map values) for the task instance. | |
isPooled | A boolean | Returns true if this is a pooled task instance, otherwise returns false. A pooled task instance is one which may be assigned to a group of users and then one of those users may take ownership of the task and progress it. |
?? Should setProperties and setPooled be included here? I don't think these methods should be in this API.
Name | Params | ReturnType | Description |
---|---|---|---|
endTask | String transitionId: The id of the transition to be used. | Void | Ends the task and signals the associated workflow path to progress to the next node using the specified transition. |
The workflow transition is a simple DTO representing a single transition type. This object has no behaviour, just some simple properties.
Name | Params | ReturnType | Description |
---|---|---|---|
getDescription | A String description | Returns the description for the workflow path. | |
getId | A String id | Returns the id for the workflow path. | |
getTitle | A String title | Returns the title for the workflow path. |