trying to use N/email and keep getting this: {"ty...
# suitescript
s
trying to use N/email and keep getting this: {"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":null,"stack":["doSendEmail(N/email)","afterSubmit(/SuiteScripts/afterSubmit_newCustomer_Approval.js:31)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":null,"userEvent":"aftersubmit","stackTrace":["doSendEmail(N/email)","afterSubmit(/SuiteScripts/afterSubmit_newCustomer_Approval.js:31)"],"notifyOff":false},"id":"9a9b6871-8bf8-46ac-b20c-11a7a2086229-2d323032322e30342e3132","notifyOff":false,"userFacing":false} What could be the issue?
e
check line 31 of your UE
s
thats the start of email.send. Its super bare bones email.send({ author: senderId, recipients: recipientEmail, subject: 'SUBJECT', body: 'BODY.', });
define(['N/record','N/log', 'N/email'], function (record, log, email) { function afterSubmit(context){ if (context.type !== context.UserEventType.CREATE) return; //Trigger on record CREATE var objRecord = context.newRecord; //Create object const newCustId = objRecord.id; const senderId = "4346"; //senderID of "Don't Reply" const recipientEmail = "workingemail@asd.com"; //for testing //let timeStamp = new Date().getUTCMilliseconds(); log.debug({ title: "Checks", details: "CustID = " + newCustId + "||" + senderId + " " + recipientEmail }); email.send({ author: senderId, recipients: recipientEmail, subject: 'SUBJECT', body: 'BODY.', }); } return { afterSubmit : afterSubmit } });
purpose of this test is just to send an email when i new customer record is created\
s
Make sure senderId and recipientEmail have values
s
yea i changed those values for anonymity but recipientID is a valid email i use regularly and senderID is the internal ID of a placeholder Employee i made
s
senderID looks to be a string, try an integer
4346 instead of “4346”
s
I initially did it as an Int but changed it to string to see what happens. Same outcome
s
Are you in production or a sandbox, release prevew, dev, etc?
s
production
s
Hmm I’ve only seen that thrown before when I was in Release Preview because the Email domains do not carry over from Prod like they do to Sandbox
First time using N/email?
s
does the email need to exist witin NS somewhere. Or can it be any valid email
yea
s
Right yes, you need to setup your Production environment to send emails
In NetSuite Help center go to /app/help/helpcenter.nl?fid=book_1556559731.html
“Email for Administrators”
follow the setup steps, I hope this helps
s
AH yes i believe thats it. I disabled outgoing emails because of how much our clients get them as spam
Thanks
s
You’re welcome 🙂
s
wait i might have jumped the gun. Is there some checkbox in the settings that enables/disables all outgoing emails from our account?
i think ill just implement this via saved search notifications. Not really sure whats going on...