Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Eval() need to be replaced with GlideScriptEvaluator

sushmachava
Tera Contributor

Hi Can any one help me updating the below script with glide script evaluator instead of eval

 

parseMailScriptCode : function (sScriptData, sTable, sRecordID, newColor, email_action ) {  
    try {  
        var scriptRegex = new RegExp("<mail_script>([\\s\\S]*?)<\\/mail_script>","i");
        if ( scriptRegex.exec(sScriptData)[1] != undefined ) {
            var current = new GlideRecord(sTable);
            current.get(sRecordID);
            var email = new GlideEmailOutbound();
            var sTempCode = scriptRegex.exec(sScriptData)[1];
            sTempCode = sTempCode.replace('email.setBody(sHTML);', '');
            sTempCode = sTempCode.replace('email.setSubject(sSubject);', '');
            if ( newColor != null && newColor != "" ) {
                sTempCode = sTempCode.replace(/(var ([^"]+) = new EmailFormatter([^;]*))/, "$1;$2.BORDER_COLOR=\""+newColor+"\"");  
            }
            sTempCode = eval(sTempCode);
            sTempCode = sTempCode.replace(/&(nbsp|amp|quot|lt|gt);/g, '');
            if ( sHTML != undefined ) {
                sTempCode = sHTML;  
            }
            this._debugLog('parseMailScriptCode output:\n\n'+sTempCode);
            return sTempCode;
        } else {
            return "";
        }
    } catch (err) {
        return 'Error in parsing email: ' + err;
    }

   },
   
0 REPLIES 0