I think this is probably a dumb question, but how can I loop over query results in an email body?
I can't seem to get a for loop to work inside the {{}} brackets. Is there a better way?
I think this is probably a dumb question, but how can I loop over query results in an email body?
I can't seem to get a for loop to work inside the {{}} brackets. Is there a better way?
You probably want to have a code block in between the email and the query results the performs the formatting. For example, you can have something like
const lines = []
for (const row of query1.data) {
lines.push(`Sales order: ${JSON.stringify(row)}`)
}
return lines.join('\n')
and in your email body, you can use {{code1.data}}
(or whatever the name of the block is) instead of query1.
Yep - I should have thought of this. Thank you! Makes perfect sense.