glide evaluator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 09:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 09:54 AM
Hi @RiteshI ,
You don't need GlideScopedEvaluator for this
try this
getDynamicValue: function(valueString, table, record, displayValue, doNA) {
var returnVal = valueString;
var regexp = /\{([^}]+)\}/g;
var toReplace;
while ((toReplace = regexp.exec(valueString))) {
var replaceVal;
var field = toReplace[1].toString();
toReplace = toReplace[0].toString();
var rec = new GlideRecord(table);
if (rec.get(record)) {
if (displayValue == true)
replaceVal = rec[field].getDisplayValue(); //eval ('rec.' + field + '.getDisplayValue()');
else
replaceVal = rec[field]; //eval('rec.' + field);
//If replaceVal is nil and it's not a barcode field, return 'N/A'
if (replaceVal == '' && doNA == true)
replaceVal = 'N/A';
returnVal = returnVal.replace(toReplace, replaceVal);
if (this.debug == 1)
gs.log('BarGen: Returning dynamic value = ' + replaceVal);
}
}
return returnVal;
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 10:05 AM
but I know I dont need glide evaluator for this but for other script I need so I wanted to know how to implement glideEvaluator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 10:14 AM
HI @RiteshI ,
GlideEvaluatorAPI is usually meant for running script inside the script fields
in your scenario there is no scope for this API.
//setting up a record that contains the script to be executed.
//Example from docs
var now_GR = new GlideRecord('u_global_table');
now_GR.u_short_description = 'Calculate Addition';
now_GR.u_test_script = "result = x + y";
evaluator.evaluateScript(now_GR, "script")
now_GR.insert();
var evaluator = new GlideScopedEvaluator();
evaluator.putVariable('x', 100);
evaluator.putVariable('y', 200);
evaluator.putVariable('result', null);
evaluator.evaluateScript(now_GR, "script") //now_GR is the GlideRecord and "script" is the script field bakend name
now_GR.insert();
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 10:35 PM
hey @Chaitanya ILCR can I make use of glideEvaluator in UI script