glide evaluator

RiteshI
Tera Contributor
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 = eval ('rec.' + field + '.getDisplayValue()');
                else
                    replaceVal = 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;
    }---------------->want to replace eval with glide evaluator ?
 
11 REPLIES 11

ben_hollifield
Tera Guru

Hey @RiteshI - I recognize that code. I believe I wrote it a few years back. 🙂

 

I'm glad to see you're still getting some value from the old version of Barcode Generator. I want to make you aware that we do now have a certified & supported version of that app available on the ServiceNow Store. It's a paid app, but the code-base has been entirely updated to modern best practices, and it is now fully supported and has significant updates to the legacy version. If it is something you might need, you can check it out at the link below. Thanks!

 

Yansa Barcode & QR Code Generator on the ServiceNow Store

🙂