This topic contains 3 replies, has 0 voices, and was last updated by david.smith 7 years, 3 months ago.

  • Author
    Posts
  • #18350

    NateS

    I’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 = ‘

    Spotix Family of stores
       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.6849Spotix benefits
    ‘;
    This is a cached copy. Click here to see the original post.

  • #18351

    jmacdonald

    If I was trying to add javascript variables to a string like that I would just concatenate using +. Using your example:

    ‘ + cusName + ‘,
  • #18352

    NateS

    Originally 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.

  • #18353

    david.smith

    NateS 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.

You must be logged in to reply to this topic.