Scoped GlideEvaluator - putVariable(String name, Object value)

Puts a variable into the GlideScopedEvaluator object. These variables are available to the script that this GlideScopedEvaluator object runs.

Table 1. Parameters
Name Type Description
name String The name of the variable.
value Object The value of the variable.
Table 2. Returns
Type Description
/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"; 
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'); 
if ( { 
    evaluator.evaluateScript(gr, 'calculate', null);'result'));

Output: 300