OpenWGA 7.6 - TMLScript reference

WGA » WGA.Master
Method :

runFunction([context,] function [, param1, param2, ...])

On object WGA.Master
Usage Runs a JavaScript function under master session rights
Description This is an alternative for master actions which enables a normal TMLScript code to execute certain code parts under master rights. The code part has to be defined in a JavaScript function which is to be given as parameter "function". The function runs under the normal environment of WebTML master actions with the same possibilities and limitations.

You can parametrize the master function by parameters which will be given to the function as normal JavaScript function parameters. So you must declare them in the function definition header to use them.

The JavaScript function will be executed under the same context as the calling script unless a context parameter is given.

This function is not suitable for calling methods of TMLScript objects because it will overwrite the object context. Use WGA.Master.runMethod() instead for this purpose.

For backward compatibility there still is a global function "runMasterFunction()" available whose use is discouraged since OpenWGA 5.3.

Parameters context (TMLContext, optional):
A context under which to execute the function. This will be the context available as "this" object to it.

function (JavaScript function):
The function to run under master session rights.

param1...paramN (Object, optional):
Parameters that will be given to the function as function parameters (NOT WebTML action parameters!)
Return value The return value of the master function
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events

A simple example which runs a function that is defined "in-place". It receives a parameter p1 that is declared in the function header and which gets the string "The param":

 function(p1) {"Now I am: " + db().getSessionContext().getUser());"The parameter:" + p1); 
 "The param"