Graphql
Alfresco Activiti Workflow API
Alfresco implements it's own Activiti Workflow API. This document shows you how to use it.
General information
The essential parts of an alfresco activiti workflow are ProcessDefinition
s, Process
es and Task
s.
A process definition defines what happens if you start a process, complete tasks of a process, abort the process etc.
The process itself starts all the tasks defined in the process definition and may delegate them to certain users. It holds information about it's own progress and may take care of notifications, expirations etc.
A task is a part of a process and can be assigned to a user, delegated to another user or beeing completed.
Process definitions
As mentioned, before starting a process, you need a process definition. You can search for them, or if you already know which to use, require a process definition by its id.
Search process definitions
This query provides you with a filterable, sortable, paginatable connection
query SearchProcessDefinitions {
alfrescoWorkflowProcessDefinitions(
paging: { first: 10 }
sort: { by: name }
where: { name: { startsWith: "test" } }
) {
id
key
version
name
category
}
}
Find a process definition by its id
Retrieve a single process definition by its ID
query FindProcessDefinition {
alfrescoWorkflowProcessDefinition(id: "xxx"){
id
key
version
name
category
}
}
For a full list of fields you can require from a AlfrescoWorkflowProcessDefinition
, please have a look into the playground docs.
Processes
Start a process
As soon as you know which process definition to use, you can use its key
field to start a process with the corresponding mutation
Start a process given a process definition key, one or multiple assignees/groupAssigneees and a set of custom variables (defined within the alfresco model definition of the process)
mutation StartProcess {
startAlfrescoWorkflow(
processDefinitionKey: "some definition key"
assignees: [{ cn: "mmustermann" }]
variables: { a: "some", b: "variables", c: 4, d: [1, 2, 3] }
): AlfrescoWorkflowProcess!
}
Search processes
You can retrieve a pageable, sortable filterable (in this case only active processes) Connection of processes by using
query SearchProcesses {
alfrescoWorkflowProcesses(
paging: { first: 10 }
sort: { by: startedAt, order: DESCENDING }
where: { status: { eq: active } }
) {
nodes {
id
name
priority
description
status
}
}
}
Find a process by its id
If you know the id of a process you can retrieve it like this:
query FindProcess {
alfrescoWorkflowProcess(id: "xxx") {
id
name
priority
description
status
}
}
For a full list of fields you can require from a AlfrescoWorkflowProcess
, please have a look into the playground docs.
Delete/abort a process
To abort a process execute the following mutation:
mutation DeleteProcess {
alfrescoWorkflowProcess(id: "xxx") {
delete {
success
}
}
}
This mutation stops the process with the given id and also stops all connected tasks. It returns a field success
that tells you if the operation was successful.
Tasks
Search tasks
You can retrieve a pageable, sortable filterable (in this case only priority 1) Connection of tasks by using
query SearchTasks {
alfrescoWorkflowTasks(
paging: { first: 10 }
sort: { by: startedAt }
where { priority: { eq: 1 } }
) {
nodes {
id
name
description
dueAt
owner {
cn
}
assignee {
cn
}
}
}
}
Find a task by its id
If you know the id of a task you can retrieve it like this:
query FindTask {
alfrescoWorkflowTask(id: "xxx") {
id
name
description
dueAt
owner {
cn
}
assignee {
cn
}
}
}
For a full list of fields you can require from a AlfrescoWorkflowTask
, please have a look into the playground docs.
Reassign/delegate a task
This mutation assigns the task with the given id to a user with the cn newCN
. It returns the updated AlfrescoWorkflowTask
mutation DelegateTask {
alfrescoWorkflowTask(id: "xxx") {
delegate(assignee: "newCN") {
assignee {
cn
}
}
}
}
Claim a task
This mutation assigns the task with the given id to the logged in user. It returns the updated AlfrescoWorkflowTask
mutation ClaimTask {
alfrescoWorkflowTask(id: "xxx") {
claim {
assignee {
cn
}
}
}
}
Resolve a task
This mutation resolves/completes the task without any updates to variables by setting the status of the task to resolved
. It returns the updated AlfrescoWorkflowTask
mutation ResolveTask {
alfrescoWorkflowTask(id: "xxx") {
resolve {
status
}
}
}
Update a task
This mutation updates the task. Possible changes (vie the input
parameter) are changing the state
(i.e. completing the task), reassign it to another user by setting the assignee
or updating local (task) or global (process) variables. It returns the updated AlfrescoWorkflowTask
mutation ResolveTask {
alfrescoWorkflowTask(id: "xxx") {
update(input: { localVariables: { newVariable: "test" } }) {
variables
}
}
}