Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Nayan Mahato
Tera Guru

GlideScopedEvaluator- Very useful to evaluate scripts in a GlideRecord field from both scoped and global server scripts.

The GlideScopedEvaluator API allows you to evaluate scripts in a GlideRecord field from both scoped and global server scripts.
The GlideScopedEvaluator API evaluates scripts within the script field type. The scope of the record defines the scope of the script.
 
The most common method used from these APIs- 
 
evaluateScript(GlideRecord grObj, String scriptField, Object variables)-
 
//For this example, we created a table: "x_custom_table" with two columns: "short_description", "test_script" // "test_script" will store the script to be evaluated by GlideScopedEvaluator.
var test_GR = new GlideRecord('x_custom_table');
test_GR .short_description = 'Testing GlideScopedEvaluator APIs Method';
test_GR.u_test_script = gs.getUser().getName() + " says " + "Hi/Hello";
test_GR.insert();

//setup variables to be used by the script
var vars = {'Hi/Hello' : 'hello'}; //Evaluate the script from the field
var evaluator = new GlideScopedEvaluator();
//gs.info(evaluator.evaluateScript(test_GR , 'test_script', vars));
// Now retrieve the result
evaluator.evaluateScript(test_GR , 'u_test_script', vars);
gs.info(evaluator.getVariable('result'));
Version history
Last update:
‎04-25-2022 01:24 PM
Updated by: