@karlenigma
function ReplaceStrings(scriptContext) {
if(runtime.executionContext === runtime.ContextType.CSV_IMPORT || runtime.executionContext=== runtime.ContextType.USERINTERFACE) {
var modelRec = scriptContext.newRecord;
var modelName = modelRec.getValue({fieldId: 'name'});
var productNum = modelRec.getValue({fieldId: 'custrecord_model_product_number'});
var modelNamealt = modelName.replace(/["-.-/\"]/g,'');
var productNumalt = productNum.replace(/["-.-/\"]/g,'');
modelRec.setValue({fieldId: 'custrecord_model_alt_product_number', value: productNumalt});
}
}
You don't need to write the if condition.....if it finds the special character it will replace automatically. Otherwise it will return as it is.
Don't use the variable to store special character. (when It contains the backward slash)