I'm trying to build a Workflow that retrieves some data from the database and sends it as a CSV via email. My workflow has 3 blocks:
A PostgreSQL query retrieving the data
A JS block running "Papa.unparse" over the retrieved data to transform it to the CSV format
A SMTP block to send the data via email
Everything is working fine up until the unparse, but I'm not sure how I can make use of the data returned by the JS and plug it into the SMTP query so it's sent as a CSV file via email.
Here's an image of where I'm stuck at. In the SMTP query, I clicked "fx" to set the value dynamically. I then tried using both "{{code}}" and {{code.data}}" as a value, but I then get the error below when I try to run the SMTP block:
Exact same issue attempting the same thing
three blocks
data query
Papa.unparse
smtp block = [{data: {{btoa(code.data)}}, name: "attachment.csv", fileType: "csv" }]
Tried the suggestion, still the same error "Use File Input component to upload a file and ensure file is uploaded before query is fired."
Yep! You can add the SheetJS library which is particularly useful for handling xlsx files to your Workflow @Leon:
Similar to PapaParse, it has APIs for reading and writing data. The following code takes the result of a Retool DB query and returns an xlsx file as a base64 string: