Skip to content

ListCases

Returns a list of cases on the specified channel.

1
$Domain.ListCases(channelId?: string, query?: string, start?: number, length?: number, columns?: string, orderBy?: string, order?: string):DataTable

Parameters

string channelId optional
    The ID of the channel. Optional. If not specified, the search is performed across all channels.

string query optional
    A query to execute on the cases.

number start optional
    The starting number of the results. The default is 0.

number length optional
    The maximum number of results to return. The default is 100.

string columns optional
    A comma-separated string of column names to include in the result. If not specified, all columns are returned.

string orderBy optional
    The column to order the list results by.

string order optional
    The type of ordering for the list results.

Returns

An instance of DataTable that contains the case list.

Remarks

The query syntax is based on the full-text engine query language. A missing query defaults to open cases (IsClosed:\"false\"). columns is a comma-separated projection, and omitted channelId searches all channels. In the current backend implementation, the orderBy and order arguments are forwarded in reverse order; use the default ordering unless that behavior has been verified for the installed version.

Examples

Query: a word in the subject

1
Subject:foo

Query: a phrase in the subject

1
Subject:"foo bar"

Query: a phrase in the subject and a case number

1
Subject:"foo bar" and Number:123

Query: cases closed in a date range

1
ClosedAt:[2020-01-01 TO 2021-01-01]

List open cases and cases closed in a period

1
2
3
4
5
6
7
8
var channelId = $Xml.Evaluate('ChannelId');
var columns = ["Id", "Subject", "Number", "CreatedAt", "CreatedBy", "CreatedByName", "UpdatedAt", "ClosedAt", "IsClosed", "TotalTimeSpent", "Priority"].join(',');

var query = "IsClosed:'False' OR ClosedAt:[" + $Xml.EvaluateDateTime('Start').toJSON() + " TO " + $Xml.EvaluateDateTime('End').toJSON() + "]";

var cases = $Domain.ListCases(channelId, query, 0, 1000, columns);

console.log('found ' + cases.RowCount() + ' case');

See Also