OpenWGA 7.11 - OpenWGA Concepts and Features

Design and development » TMLScript » TMLScript Objects

TMLScript globals

Instead of instanciating a TMLScript object each time you need it you can define the script module as "global".

A global TMLScript module is registered by calling<global-name>, <tmlscript-module-design-locator>)

This is typically done in a connect script of an app.

Sample:"Products", $.Products)

You can access this "global" in any TML or TMLScript inside the design of your app (but not outside) through the global name you registered it:


The TMLScript object itself is instanciated by the OpenWGA runtime. By default the object will be instanciated the moment it is used the first time (and it will not be instanciated if never used) and stays in memory until the app is disconnected. You can however tell OpenWGA to instanciate a new object on each HTTP request or for each HTTP session by specifying an optional "scope" parameter when registering:<global-name>, <tmlscript-module-design-locator>, {

  scope: <scope>


Available Scopes are

  • WGA.Scopes.APP (the default)
  • WGA.Scopes.CALL (new object for each HTTP request)
  • WGA.Scopes.SESSION (new object for each HTTP session)
  • WGA.Scopes.TMLPAGE (new object for each Websocket connection)
  • WGA.Scopes.FORM (new object for each TMLForm)