
Nayan Mahato
Tera Guru
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 04-25-2022 01:24 PM
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'));
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'));
- 779 Views