``` var tempStr = emailMerged.body; tempStr...
# suitescript
s
Copy code
var tempStr = emailMerged.body;
    tempStr.replace(/<!--packagetrackingnumberups-->/,trackingNumberMsg);
    log.debug({title:"tempStr",details:tempStr})
    emailMerged.body.replace("<!--packagetrackingnumberups-->",trackingNumberMsg);
    log.debug({title:"emailMerged.body.after",details:emailMerged.body});
took me hours to debug, was using the N/render module and the merged email, can anyone tell me why emailMerged.body.replace() dont work? :< had to use a dummy variable 🤦‍♂️
b
what do you expect to happen vs what happened
as far as i can tell, your code does nothing, String.prototype.replace() probably doesnt do what you expect it to do
s
Copy code
var emailMerged = render.mergeEmail({templateId:29,transactionId:newRec.id});
emailMerged.body.replace("<!--packagetrackingnumberups-->",trackingNumberMsg);
log.debug({title:"emailMerged.body.after",details:emailMerged.body}); //doesn't work
var tempStr = emailMerged.body;
tempStr.replace("<!--packagetrackingnumberups-->",trackingNumberMsg);
log.debug({title:"tempStr",details:tempStr})//works
Let me explain so this is what happened, I did a emailMerged using the render module, then I tried to do the emailMerged.body.replace() thinking that I could change it, I think 2 hours into debugging I realized that actually I couldn't do .replace directly i.e emailMerged.body.replace, instead I had to use a dummy variable and let the .replace act on the string
🤦‍♂️ I spent a long time thinking it was because of the escape characters or how the .replace was acting on the escape characters not knowing that actually it wasn't working because probably emailMerged.body.replace() wasn't a valid operation
b
neither of the code should log anything interesting
you ignore the output of the replace function
s
ah yes
maybe that's why it didn't work
i'll try it again thanks!!