Global scripts are added to the scripts specified for meta points, point links, and anywhere else that scripts are used. This allows users to declare code such as functions or general initializations in a single place. Multiple global scripts can be added to simplify code management, but a single script can contain an arbitrary amount of declarations. Scripts are applied in alphabetical order by their names.

Global scripts must be independently executable, i.e. they cannot reference variables from other scripts.

Scripts are written in JavaScript, also known as ECMAScript. (The full specification for ECMAScript is available here .) JavaScript is arguably the most popular scripting language in use today, it being the only language available for use in every popular web browser. The result is that, by far the common usage of JavaScript is in web pages. The context within the Meta data source is of course different, there being no “window” or “document” objects, among other more subtle differences. Contextual differences aside, a full and complete implementation of ECMAScript is available. Specifically, the Rhino implementation is used.

Simple Global Script Examples

Example 1

This script named “myProduct”, simply takes two arguments, multiplies them together, and returns the product.


function myProduct(arg1, arg2)
   return arg1 * arg2;


Example 2

This script named “myConvertFtoC” only takes one argument (arg1), which will be a temperature given in degrees Fahrenheit. The function converts the value to degrees Celsius and returns it.


function myConvertFtoC(arg1)
   return (arg1 - 32) * (5/9);

How The Global Scripts Look In Mango

Example of calling a global script from a Meta Data Source script

In this example we have a Meta Data Source named celsiusView which has a script that converts the value from OutsideTemp from Fahrenheit to Celsius using the global script myConvertFtoC.


return myConvertFtoC(OutsideTempF.value);


How the Meta Data Source script looks in Mango