Toggle menu

getQueryTasks

Query the indexed task collection. Note that only active tasks are indexed, once a task has been completed it is also removed from the search index.

Parameters

NameTypeDescription
useQueryServiceBooleanThis should always be set to true. It is present for backwards compatibility and will be removed in a future release
filterObjectReturn tasks matching the provided filter
startNumber(Optional) Where to start the result set from, defaults to 0
limitNumber(Optional) How many results to return defaults, to 10
sortOrderArray<Object>(Optional) Enables multi-column ordering. For example [{"dueDate": "asc"}].

Available sort values: dueDate, creationDate, processDescription and description.

Note that when sorting by dueDate, tasks without a date will always appear last

Filter Keys

The following keys can be used when building filters to query indexed tasks.

NameTypeDescription
assignedBooleanOnly supports "false" and the "EQ" operator allows tasks to be retrieved that are not assigned to a user
assigneeStringThe user assigned to a task
candidateStringThe candidate users for a task
candidateGroupsStringThe candidate groups for a task
createTimeString (ISO8601)The create time of the task
descriptionStringThe task description
dueDateString (ISO8601)The due date of the task
processBusinessKeyStringThe business key of the process the task belongs to
processDefinitionKeyStringThe key for the process definition the task belongs to
processDescriptionStringThe expanded process description for the process the task belongs to
suspendedBooleanWhether the task is part of a suspended process instance or not.

If this key isn't set in a filter the default behaviour is to return both active and suspended tasks. Setting the workflow worker configuration property getQueryTasksExcludeSuspended: true changes the default behaviour and excludes suspended tasks when the key isn't provided

Examples

See the Filters article for further examples.

Request

A basic call from an end point finding the tasks assigned to a known user.

function(params, credentials) {
    let resp = this.callWorkerMethod("workflow", "getQueryTasks", {
        "useQueryService": true,
        "filter": {
            "key": "assignee",
            "EQ": "timg"
        }
    });
    return resp;
}

Response

Note that "processVars": {} only includes process variables that are set as searchable in the "summary form" used by the process instance (the summary form a process uses is named in the _summaryForm process variable). In most cases that will be the form that started the process instance, but a different form can be set on the Workflow - Start Action field.

{
    "list": [{
        "processVars": {
            "form_FEEDBACK": "Here's some feedback",
            "form_ISSUETYPE": "Error",
            "form_URL": "https://docs.gossinteractive.com/article/7747/getQueryProcesses"
        },
        "id": "240026",
        "taskDescription": "Review feedback for https://docs.gossinteractive.com/article/7747/getQueryProcesses",
        "assignee": "timg",
        "candidateGroups": ["staff"],
        "candidateUsers": [],
        "canUnclaim": true,
        "processInstanceName": "Feedback Review",
        "processInstanceId": "240001",
        "processDefinitionKey": "feedbackreview",
        "createTime": "2022-02-18T15:08:40Z",
        "dueDate": null,
        "processDescription": "Review comments from the feedback form",
        "businessKey": "5168-8848-3661-2384",
        "parentBusinessKey": null,
        "parentProcessId": null,
        "suspended": false
    }],
    "count": 1,
    "time": 5,
    "debug": null
}

Request

This example has a more interesting filter and sorts the results.

function(params, credentials) {
    let resp = this.callWorkerMethod("workflow", "getQueryTasks", {
        "useQueryService": true,
        "filter": {
            "key": "candidateGroups",
            "IN": [{
                    "EQ": "cm-feedback-manager"
                },
                {
                    "EQ": "cm-feedback"
                }
            ]
        },
        "sortOrder": [{
            "creationDate": "desc"
        }],
        "limit": 20
    });
    return resp;
}

Request

Finding tasks due in a particular date range.

function(params, credentials) {
    let resp = this.callWorkerMethod("workflow", "getQueryTasks", {
        "useQueryService": true,
        "filter": {
            "key": "dueDate",
            "RANGE": ["2024-03-01T14:00:00Z", "2024-03-011T14:00:00Z"]
        },
        "sortOrder": [{
            "creationDate": "desc"
        }],
        "limit": 20
    });
    return resp;
}

Last modified on April 24, 2024

Share this page

Facebook icon Twitter icon email icon

Print

print icon