Craig
09/19/2024, 9:29 PMconst template = render.mergeEmail({
templateId: 37,
transaction: {
type: 'salesorder',
id: transactionData.transactionId
}
})
I'm trying to get sales order fields into an email template but the template is being sent without values. Does this code look correct?eminero
09/19/2024, 9:39 PMconst mergeResult = render.mergeEmail({
templateId: SCRIPT_PARAMETERS.EMAIL_TEMPLATE,
transactionId: recordId
});
This is what I have used before.Craig
09/19/2024, 9:41 PMCraig
09/19/2024, 9:41 PMconst template = render.mergeEmail({
templateId: 37,
transactionId: transactionData.transactionId
})
Craig
09/19/2024, 9:42 PMeminero
09/19/2024, 9:44 PMtransactionData.transactionId
is a number and has a value. the example share is using a sales order and it is working perfectly. I'm working right now on the script that uses it. Zero issues.Craig
09/19/2024, 9:44 PMCraig
09/19/2024, 9:44 PMCraig
09/19/2024, 9:45 PMeminero
09/19/2024, 9:47 PMconst emailSubject = mergeResult.subject;
var emailBody = mergeResult.body;
Then, I would try to remove any expression and just see if a simple plain template works. I guess it si something wrong with the template.Craig
09/19/2024, 9:48 PMCraig
09/19/2024, 9:48 PMCraig
09/19/2024, 9:48 PMfunction sendTemplatedEmail(transactionData) {
const senderId = 47165;
const recipientEmail = transactionData.customerEmail;
const template = render.mergeEmail({
templateId: 37,
transactionId: transactionData.transactionId
})
const emailSendOptions = {
author: senderId,
recipients: recipientEmail,
subject: template.subject,
body: template.body,
relatedRecords: {
transactionId: transactionData.transactionId
}
}
email.send(emailSendOptions);
}
FYI: This is the entire functionCraig
09/19/2024, 9:49 PM<p>Dear ${transaction.entity.firstname}</p>
Then these fields in the email are all emptyCraig
09/19/2024, 9:50 PMCraig
09/19/2024, 9:53 PMconst template = render.mergeEmail({
templateId: 37,
transaction: {
type: 'salesorder',
id: transactionData.transactionId
}
})
It sends with this though, but I'm using a transaction{} whereas you're not.Craig
09/19/2024, 9:53 PMeminero
09/19/2024, 9:55 PMconst mergeResult = render.mergeEmail({
templateId: SCRIPT_PARAMETERS.EMAIL_TEMPLATE,
transactionId: recordId
});
const emailSubject = mergeResult.subject;
var emailBody = mergeResult.body;
emailModule.send({
author: SCRIPT_PARAMETERS.EMAIL_SENDER,
recipients: email,
subject: emailSubject,
body: emailBody
});
${transaction.entity}
and ${transaction.tranId}
should work. Well, really weird. Glad you made it work.Craig
09/19/2024, 9:57 PMCraig
09/19/2024, 9:57 PMCraig
09/19/2024, 9:58 PMCraig
09/19/2024, 9:58 PMconst template = render.mergeEmail({
templateId: 37,
transaction: {
type: 'salesorder',
id: transactionData.transactionId
}
})
No error with the above code, email template send, fields are emptyCraig
09/19/2024, 9:58 PMconst template = render.mergeEmail({
templateId: 37,
transactionID: transactionData.transactionId
})
Above code throws an error, no email sends.eminero
09/19/2024, 10:01 PMCraig
09/19/2024, 10:02 PMCraig
09/19/2024, 10:03 PMCraig
09/19/2024, 10:03 PMCraig
09/19/2024, 10:03 PMeminero
09/19/2024, 10:05 PMCraig
09/19/2024, 10:05 PMStefan Reeder
09/22/2024, 1:00 AMconst template = render.mergeEmail({
templateId: 37,
transactionId: Number(transactionData.transactionId)
})