Scoped GlideEvaluator - evaluateScript(GlideRecord grObj, String scriptField, Object variables)

Evaluates a script from a GlideRecord field.

Table 1. Parameters
Name Type Description
grObj GlideRecord The GlideRecord containing a script expression.
scriptField String (Optional) The name of the field containing the script expression.
variables Object (Optional) A map of variables with name-value pairs. These variables are available to the script during execution of this method.
Table 2. Returns
Type Description
Object The result of the script execution.
// For this example, we created a table: "x_app_table" with two columns: "short_description", "test_script"
// "test_script" will store the script to be evaluated by GlideScopedEvaluator.
gr = new GlideRecord('x_app_table'); 
gr.short_description = 'Testing GlideScopedevaluator';  
gr.test_script = "gs.getUser().getName() + ' says ' + greeting; "; 
// setup variables to be used by the script
var vars = {'greeting' : 'hello'};
//Evaluate the script from the field
var evaluator = new GlideScopedEvaluator(); 
gr = new GlideRecord('x_app_table'); 
gr.addQuery('short_description','Testing GlideScopedevaluator'); 
if ( {, 'test_script', vars));

Output: admin says hello