OpenWGA 7.6 - TMLScript reference




Represents an object carrying all resulting data of a document collection.

This is the parent class for objects QueryResult and NavigatorResult which represent collection results of a query or navigator respectively, defining shared functionality of both. A CollectionResult is also created by methods that modify an existing collection result by filtering it or skipping its first results.

Methods that create new CollectionResult objects with modified versions of the original CollectionResult, like filter() and skip(), may be freely cascaded. So you can apply multiple filters and do multiple skips on a collection result.

A CollectionResult is iterable in JavaScript, so it may be used as parameter for the JavaScript function Iterator(). The returned objects are TMLContext objects for the result contents.




Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Properties and methods
Name Purpose
each(function) Applies a function to each element of the collection result.
exclude(context) Filters out the given document from the collection result
filter(function) Applies a filter to the collection result
firstResult Returns the first result document of the collection
firstResultContent Returns the first result document of the collection as WGAPI content object
getPage([offset,] length) Returns a page of result documents
getSingleValue(itemName) Returns the value of an item from the first result document of this collection
isEmpty() Tests if the result has at last one elements, the current user can read.
originalResult Returns the original QueryResult or NavigatorResult of this collection result
size Returns the number of result documents in the collection
skip(size) Skips the first documents in the current collection result

Iterating over a CollectionResult, actually a NavigatorResult here, using a JavaScript iterator. The variable cx is filled with TMLContext objects pointing to the result documents:

for (let cx in Iterator(WGA.nav().children())) {;


Same as



An example of creating CollectionResults with special modifications in a cascaded way. FIrst we implement a filter to exclude documents being older than 1 month, then we skip the first 10 documents. Finally we retrieve a collection page of 5 documents, being the first 5 documents of the collection which a) are behind the first 10 documents and b) are modified in the recent month:

var theFilter = function (cx) cx.LASTMODIFIED > WGA.modifyDate(WGA.createDate(), "M", -1);

var nav = WGA.nav().children().filter(theFilter).skip(10);

var page = nav.getPage(5);