Ways to Include Dynamic Values in Saved Search Email Content

1. Using {fieldID} Tokens (for Single-Record Results Only)

  • When your saved search returns only one record per email, you can insert field values dynamically like this:
css

Copy

Edit
Hello,

A new sales order has been created:
- Order Number: {tranid}
- Customer: {entity}
- Amount: {total}
- Date: {trandate}

Thank you.
  • These tokens pull directly from the column IDs in the saved search.
  • This does NOT work when you’re grouping or summarizing data.

2. Use the {results} Token (for Multi-Record Emails)

  • In the “Single-Record Results” section of the Email tab:
  • Use {results} to output a list of matching rows.

Example:

text

Copy

Edit
The following Sales Orders were updated:

{results}
  • This outputs the saved search results as a table in the email.

3. Formula-Based Email Body Content

  • Use this syntax:
html

Copy

Edit
<%= 'Total Amount: $' + {total} %>
  • This allows you to combine static text and field values, and format them inline.

Note: This also works with simple JavaScript-style expressions, like:

html

Copy

Edit
<%= 'Order Amount (w/ tax): $' + ({total} * 1.1) %>

4. Email Format Options

In the Saved Search > Email > Customize Message section, you can:

  • Choose to Embed Results in Email.
  • Attach results as:
  • CSV
  • Excel (XLS)
  • PDF

5. Disable “Include View Record Link”

  • If you don’t want a link to each individual result record in the email, uncheck this option.
  • This makes the email cleaner, especially for external recipients.

6. Custom HTML Email Body

  • You can write the entire email content as HTML:
html

Copy

Edit
<html>
<body>
  <p>Hello,</p>
  <p>Your recent order details:</p>
  <ul>
    <li>Order #: {tranid}</li>
    <li>Date: {trandate}</li>
    <li>Total: {total}</li>
  </ul>
</body>
</html>
  • Works well when using “Send in HTML Format” checkbox.

🔁 Advanced Option: Use SuiteScript

If you need more flexibility, such as:

  • MAX, COUNT, SUM
  • Custom logic
  • Complex formatting

Then you can use SuiteScript (Scheduled Script or Map/Reduce) to:

  • Run the saved search
  • Build your own HTML body
  • Send dynamic emails using email.send()

Let me know if you’d like a sample script template for that as well.

Leave a comment

Your email address will not be published. Required fields are marked *