This topic contains 3 replies, has 0 voices, and was last updated by david.smith 7 years, 3 months ago.
-
AuthorPosts
-
July 25, 2017 at 12:04 pm #18350
NateSI’m writing a script in SandBox that sends a email to a customer when they purchase from specific vendors. I’m using the email module and a string consisting of HTML for the body of the email. The email sends just fine and the HTML table itself is formatted correctly and displaying just fine, but I need to be able to use some javascript variables like customer name, items in order, department purchased from, etc in the HTML body of the email, but using something like document.getElementById().innerHTML doesn’t seem to be working. I was wondering if there is a work around for this.
Here is an example of a variable I would use:
Code:
var custName = record.load({
type: record.Type.CUSTOMER,
id: custId,
isDynamic: false
});
Here is an example of the problem I’m having using HTML as the body of the email.Code:
, Here is the full HTML body, you’ll see some {variables} in the HTML below, those are just place holders for the actually variables so this is a little easier to read.
Code:
var emailBody = ‘Great News! Your order is on the way… Dear ,{customer} We’ve shipped your {createdfrom} Shipping Method – {shipmethod} Ship To {shipaddress} Tracking Info {shipmethod}
{trackingnumbers}Details QTY: {quantity} SKU:{custcol_item_sku} ITEM:{item.description} Thanks for your order!Questions? Call us now: Mon-Fri 8-5 CST 888.977.6849
‘;
This is a cached copy. Click here to see the original post. -
July 26, 2017 at 4:57 am #18351
jmacdonaldIf I was trying to add javascript variables to a string like that I would just concatenate using +. Using your example:
‘
‘ + cusName + ‘, -
July 26, 2017 at 12:11 pm #18352
NateSOriginally posted by jmacdonald
View Post
If I was trying to add javascript variables to a string like that I would just concatenate using +. Using your example:
Wow, I was really overthinking this. Thanks for the help.
-
July 31, 2017 at 1:37 pm #18353
david.smithNateS When I do this I will put my variables in double brackets {{myvar}} and then I will use a regular expression with a global replace to update the string.
-
AuthorPosts
You must be logged in to reply to this topic.