GlideScopedEvaluator not passing Javascript object as variable

bbarber9
Giga Expert

I am unable to pass a Javascript object as an argument to a script called via GlideScopedEvaluator. I just tried the following on a dev instance.

//script table contains name and script fields
var script_gr = new GlideRecord('x_62845_test_script');
script_gr.get('name','test_script');
var args = {
    "testObj":{"var1":1,"var2":2},
    "test":"asdf"
}
var ge = new GlideScopedEvaluator();
ge.evaluateScript(script_gr,'script',args);

The script contained in the record that the GlideScopedEvaluator is using is

(function(testObj, test){
	gs.info("Object was " + JSON.stringify(testObj));
	gs.info("String was " + test);
})(testObj, test);

The results of the script are:

ScopedRhinoObjectWrapper: not a wrappable type: java.util.HashMap
x_62845_test: Object was null
x_62845_test: String was asdf

Is this a bug or am I doing something wrong?

3 REPLIES 3

bbarber9
Giga Expert

The answer was to use the putVariable method of GlideScopedEvaluator to pass in the value. It worked like a charm after that.

hi can you please paste code after fix we are facing same issue

So I can't post the exact code, but here is a snippet that explains what I mean

var gr = new GlideRecord('table_that_has_script_field');
var ge = new GlideScopedEvaluator();
ge.putVariable('variable_name_here',yourObject);
ge.evaluateScript(gr,'script_field_name');