Scoped GlideEvaluator - getVariable(String name)

Gets a variable from a GlideScopedEvaluator object.

Table 1. Parameters
Name Type Description
name String The name of the variable.
Table 2. Returns
Type Description
Object The value of the specified variable.
//setting up a record that contains the script to be executed.
gr = new GlideRecord('x_app_table'); 
gr.short_description = 'Calculate Addition';  
gr.calculate = "result = x + y"; 
gr.insert(); 
 
var evaluator = new GlideScopedEvaluator();
evaluator.putVariable('x', 100);
evaluator.putVariable('y', 200);
evaluator.putVariable('result', null);
 
// Now retrieve the result 
gr = new GlideRecord('x_app_table'); 
gr.addQuery('short_description','Calculate Addition'); 
gr.query(); 
if (gr.next()) { 
    evaluator.evaluateScript(gr, 'calculate', null);
    gs.info(evaluator.getVariable('result'));
}

Output: