```email.send({ author: senderInfo, body: ...
# suitecommerce
b
Copy code
email.send({
				author: senderInfo,
				body: renderedMessage,
				recipients: recipientsContantInfo,
				subject: renderedEmailSubject,
				relatedRecords: {
					transactionId: transactionId,
					entityId: recipient,
					customRecord: {
						id: messageRecordId,
						recordType: MESSAGE_RECORD_TYPE_NUM
					}
				}
			});
c
Have you done a try/catch and logged the error? I would expect this is a permissions error.
b
Thanks! I will check that
c
Email send permission requires extra steps.
b
I want to have the email listed as an related record, but try catch still says unexpected
So in the email.send function, the customRecord part isn't working
c
Can you send an email without the
relatedRecords
attribute?
b
Yes, its once I add that that it breaks
c
Does the user running the script have access to that custom record?
b
I have it set as no permission required
c
Does this code work outside of SCA?
b
Oh, sorry. This is part of a Map/Reduce but I asked the question here
c
Also, I think the
id
in this part refers to the custom rec id.
Copy code
customRecord: {
						id: messageRecordId,
						recordType: MESSAGE_RECORD_TYPE_NUM
					}
Not sure if you're using the message id or not.
b
Im using the internal id of the custom record
just the name of the custom record is messageQueue
c
Well, that should work. You could always do an email.send.promise and attach it after the message is sent.
b
Ok, thanks
c
make sure the
id
is a number and the
recordType
is a string.
b
Ok, i will check that
The documentation says recordType should be the internal id of the record
c
message has been deleted
It's weird how sometimes it's okay with a string and sometimes it has to have a number.
Try "950"
b
That still doesnt work
c
er, wait, not "950", that's the record instance internalid. What't the
rectype={id}
?
b
It is 950, i sent the url from the actual custom record Record
"l?id=201&rectype=950&whence="
c
Well, that should do it.
b
Yeah, It stumps me
c
I'd throw one instance of this into a hardcoded scheduled script to make debugging it easier. Prove out the simplest use case...
b
Thanks
Turns out netsuite has a defect where you cant attach it to both a transaction and a custom record
Once I remove the transactionId part it works great
👏🏻 1
c
That's hard fought knowledge.
b
Yes it is
How could I attach a promise to the record?
c
It's dinner time here. I've marked a reminder on this tomorrow. I'll see if I can work up an example in the morning.
b
Thanks