I want to setup a function to return global variables and objects and then use eval
on them on the calling function but I'm struggling to work out how to do this.
I realise I need to return them as a string and have tried a few things. Now at this:
//global vars etc for functions
function globals(name){
let returnVal;
switch (name){
case "scEmailFindReplace":
returnVal = [
["MULTI_LINE_ADDRESS_NAME", contact.sendName],
["MULTI_LINE_ADDRESS_FLAT", "Flat "+contact.flatNum+" Glenmore"],
["INV_NO", invNum],
["INV_DATE", scVars.INV__DATE],
["DEM_DATE", scVars.DEM__DATE],
["INV_START", scVars.INV_START],
["INV_END", scVars.INV_END],
["PAY_REF", "Glen "+contact.flatNum],
["SC_NET", scVars.DEM_AMOUNT],
["SC_GROSS", scVars.DEM_AMOUNT],
["TOT_NET", scVars.DEM_AMOUNT],
["TOT_GROSS", scVars.DEM_AMOUNT]
].toString();
break;
default:
returnVal = "NOT FOUND";
break;
}
return returnVal
}
But no luck. Still tries to evaluate it before the return.