https://netsuiteprofessionals.com logo
#suitescript
Title
# suitescript
s

Scruffy

04/12/2022, 5:17 PM
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

Eric B

04/12/2022, 5:28 PM
check line 31 of your UE
s

Scruffy

04/12/2022, 5:30 PM
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

Sam

04/12/2022, 5:43 PM
Make sure senderId and recipientEmail have values
s

Scruffy

04/12/2022, 5:44 PM
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

Sam

04/12/2022, 5:44 PM
senderID looks to be a string, try an integer
4346 instead of “4346”
s

Scruffy

04/12/2022, 5:45 PM
I initially did it as an Int but changed it to string to see what happens. Same outcome
s

Sam

04/12/2022, 5:46 PM
Are you in production or a sandbox, release prevew, dev, etc?
s

Scruffy

04/12/2022, 5:46 PM
production
s

Sam

04/12/2022, 5:47 PM
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

Scruffy

04/12/2022, 5:48 PM
does the email need to exist witin NS somewhere. Or can it be any valid email
yea
s

Sam

04/12/2022, 5:49 PM
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

Scruffy

04/12/2022, 5:50 PM
AH yes i believe thats it. I disabled outgoing emails because of how much our clients get them as spam
Thanks
s

Sam

04/12/2022, 5:51 PM
You’re welcome 🙂
s

Scruffy

04/12/2022, 6:00 PM
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...