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
    The ID of the channel. Optional. If not specified, the search is performed across all channels.

string query
    A query to execute on the cases.

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

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

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

string orderBy
    The column to order the list results by.

string order
    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.

Search for the word "foo" in the Subject field:

1
Subject:foo

Search for the phrase "foo bar" in the Subject field:

1
Subject:"foo bar"

Search for the phrase "foo bar" in the Subject field AND the value 123 in the Number field:

1
Subject:"foo bar" and Number:123

Search for all cases in a closed at date range:

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

List cases on a channel:

1
2
3
4
5
6
7
8
9
var channelId = settings[0].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