I am having issues with attaching the email I send...
# suitescript
b
I am having issues with attaching the email I send in a Map/Reduce script to the transaction, I am not getting any errors. By attach, I mean to the communications tab on the transaction record in NetSuite. The email is sent and the email is being attached to the vendor record as intended,
Copy code
email.send({
                author: 23130,
                recipients: sendTo,
                subject: subject,
                body: body,
                attachments: [billPayFile],
                RelatedRecords: {
                    entityId: vendorId,
                    transactionId: billPayId
                }
            });
I have confirmed that billPayId is the internal id of the transaction and it is a number.
s
Could the receiving mail server be stripping it out? Some mail servers remove attachments of certain types (zip, pdf, etc.) based upon security rules.
b
Not the PDF attachment, I mean under the communication tab on the transaction
s
Oh, misunderstood the issue. Actually, I think the problem may be that RelatedRecords should start with a lower-case r, instead of upper case R
b
documentation shows it as a capital R and it is working for entity, the message is on the vendor record
s
hmm, okay. In all the code I have, it is always like this
s
I have never seen a CamelCase identifier in SuiteScript - so I'd bet that's a typo (RelatedRecords)
b
ok, I will give the lower case a try, thank you
s
SuiteAnswers code examples are literally riddled with typos
b
very true
I'm actually looking at the NSAPI.pdf but same
When I use the lower case r I get:
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "UNEXPECTED_ERROR",
  "message": "An unexpected SuiteScript error has occurred",
  "stack": [
    "Error\n at Object.reduce (/SuiteScripts/cbc_mr_send_billpayments.js:124:19)"
  ],
  "cause": {
    "type": "internal error",
    "code": "UNEXPECTED_ERROR",
    "details": "An unexpected SuiteScript error has occurred",
    "userEvent": null,
    "stackTrace": [
      "Error\n at Object.reduce (/SuiteScripts/cbc_mr_send_billpayments.js:124:19)"
    ],
    "notifyOff": false
  },
  "id": "",
  "notifyOff": false,
  "userFacing": true
}
s
wow, that is strange. is this running as SS 2.0 or 2.1 ?
I just noticed that someone else reported getting UNEXPECTED_ERROR from email.send in their Release Preview account. Is the account you are using on 2020.2?
b
2.1, 2020.1
the line mentioned in the error is email.send({})
s
Honestly, i’m not sure what’s wrong with the code, then. If neither RelatedRecords nor relatedRecords is working, you may need to contact support if it’s just not behaving the way it is supposed to.
b
thank you for your suggestions and help