Hello, just a quick question. Is it possible to ad...
# suitescript
j
Hello, just a quick question. Is it possible to add custom data source object in an email template? Thanks!
s
How much additional data do you need / what is the use case? There are a few ways to get additional data into email templates, the main one, if you are scripting, is to directly insert the data into your email template using a JS template engine like handlebars. You could also just do a simple string replace of known tokens with data from your script.
c
I go w/ the string replace myself if I absolutely need it.
s
we used to use (I haven't done it in a while) lodash template
_.template()
since we have lodash around all the time already, it's a solution already in our toolbox.
j
I will use this in an approval wf, the case is that our Next Approver field is a multiselect field and when pulling up the custom field in the email template, it shows as:
"Approver 1 Approver 2 Approver 3"
We want to be able to loop in the Next Approver field so we can show them as list on the email body. Something like: •
Approver 1
Approver 2
Approver 3
c
You're gonna need some scripting to do this unless you can somehow source the approvers onto the record to print from.
j
For reference, this helped me adding custom data source object in an email template https://ashabarijena.wordpress.com/2020/05/23/tip-31-use-dynamic-value-in-email-template-w[…]ed=335&moderation-hash=5b9fbbe2f3b6c06520af8faec6506fe4 (might not be applicable in all use cases).
💯 1
s
using a library for this is typically faster and less error prone.