OpenWGA 5.2 - TMLScript reference

TMLContext "this"
Method :

this.db([dbkey])

On object TMLContext "this"
Usage Returns a WGAPI object "WGDatabase", representing some content database
Description Use the dbkey parameter to specify which content database you want to be returned. Omit it to return the database of the content document currently in context.

When accessing a database that has not yet been accessed in this request OpenWGA will try to login the user to this database, using whatever login information is available. If that fails - bc. the user has no access - the database is still returned but has no open session. You can test the availability of an open session by WGDatabase method "isSessionOpen()".

The method may return OpenWGA content stores as well as data sources.

The method returns null if no database of the given dbkey is connected.
Parameters dbkey (String, optional):
Key of a database to retrieve. Omit to retrieve the current context database
Return value The database that is mapped in OpenWGA for the given key (WGAPI objekt WGDatabase)
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples The following script uses the method db() as entry point for WGAPI operations based on the database. It retrieves the available areas and returns their names:
var thedb = db("ig");
var areas = thedb.getAreas().iterator();
var result = "";
while (areas.hasNext()) {
  var area = areas.next();
  result += area.getName() + "<br>";
}
return result;