Getting a Type Error: Cannot call method "hasOwnPr...
# suitescript
m
Getting a Type Error: Cannot call method "hasOwnProperty" of null when trying to send an email in an afterSubmit UE script. Any suggestions?
Copy code
var brand_template_id = 496;
                        var objMergeResult = render.mergeEmail({
                            templateId: brand_template_id,
                            supportCaseId: parseInt(case_internal_id)
                        });
                        var template_subject = objMergeResult.subject;
                        var template_body = objMergeResult.body;
                        var sender_id_tib = 147578;
                        var send_email = nsfSendEmail(sender_id_tib, '<mailto:test.test@test.com|test.test@test.com>', template_subject, template_body, null, case_internal_id);

        function nsfSendEmail(senderid, to, subject, body, attachments, relatedRecords) {
            email.send({
                author: senderid,
                recipients: to,
                subject: subject,
                body: body,
                attachments: [attachments],
                cc: null,
                relatedRecords: {
                    entityId: parseInt(relatedRecords)
                }
            });
            return true;
        }
p
the first thing I'd do is remove the 2
null
values (
cc
and
attachments
) temporarily and test again
m
thanks for that - email got sent. shouldn't the email be shown under the record's communication?
actually that is the relatedRecord
a
@mg2017 Please be careful when use
parneInt()
without
radix
why not
Number()
?
💯 1
m
thanks