Environment API
The Environment
object has utility methods.
This method retrieves a system property from the environment. It can be used to pass credentials or other important details in to the script from outside of Smile CDR.
Inputs:
name
– The name of the system property. Note that the name must begin with either the string js.
or the string js_
in order to ensure that unintended properties do not leak into the scripting environment.Outputs:
null
if none exists.Example:
If the setenv
script contains the following declaration:
JVMARGS="$JVMARGS -Djs.authkey=12345"
Or, an External File Property Source is configured with the following property:
js.authkey=12345
The following script fragment may be used to retrieve this property:
var authKey = Environment.getProperty('js.authkey');
This method retrieves an environment variable from the host server environment. It can be used to pass credentials or other important details in to the script from outside of Smile CDR.
Inputs:
name
– The name of the environment variable. Note that the name must begin with either the string js.
or the string js_
in order to ensure that unintended properties do not leak into the scripting environment.Outputs:
null
if none exists.Example:
If the host server environment contains the following environment variable:
export JS_MYENVKEY=JS_MYENVVALUE
The following script fragment may be used to retrieve the environment variable value JS_MYENVVALUE
:
var myEnvValue = Environment.getEnv('JS_MYENVKEY');