GlideEvaluator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2018 02:56 AM
Hi All,
I have created one scripted rest api which will evaluate the script and return the result.
PFB the script.
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var table_nm = 'incident';
var table_sys_id = '6a94f7e8db1113000327771c8c9619e8';
var target_name = 'Test';
var current = new GlideRecord(table_nm);
current.get(table_sys_id);
//Set the table map name
var grTableMap = new GlideRecord('sys_script');
grTableMap.addQuery('name', target_name );
grTableMap.query();
while(grTableMap.next()){
gs.log("Using tablemap script " + grTableMap.script);
var gc = (typeof GlideController != 'undefined') ? GlideController : Packages.com.glide.script.GlideController;
gs.log(gc);
var answer = GlideEvaluator.evaluateString(grTableMap.script);
gs.print("Table map script returning: \n\t" + answer);
gs.log("Table map script returning: \n\t" + answer);
}
return {
result:answer
};
})(request, response);
When i am running the script i am getting the result as Null.Glide Evaluator.evaluate string evaluates the answer to Null.
grTableMap.script has correct values.
When i am running the same script in Script->Background it gives me correct results.
Your help would be very much appreciated here.
Regards,
Ayush
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2018 06:42 AM
Are you running this from a scoped application scripted rest api or from global? If it's scoped you'd need to use GlideScopedEvaluator().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2018 12:12 AM
Its running from Global.
If i use eval in place of evaluateString it works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 05:52 AM
Hi,
can somebody plz tell me what is use of GlideEvaluator(evaluateString('string')); ?
Thanx
Sushant
