Error attach data to Retool Email in workflow

Hello there,

I’m building a workflow to send data wich is collected in a mobile app via mail.
I’m trying to do this in a workflow as I have to generate the csv file I want to send at first.
The last step is a Retool Email component where I’m trying to use the fx-Attachment.

The giving structure is following:

grafik

I tried several ways, as you can see in the pictures:

grafik grafik

But none of them worked, I get following error again and again:
{"data":null,"error":{"error":true,"message":"Use File Input component to upload a file and ensure file is uploaded before query is fired.","isRetoolSystemError":false,"queryExecutionMetadata":{"estimatedResponseSizeBytes":147,"resourceTimeTakenMs":97,"isPreview":false,"resourceType":"retoolEmail","lastReceivedFromResourceAt":1726203840907},"data":{}}}

Am I missing something? Is there any other way?
This is the relevant part of my workflow:

Best regards
Florian

Hello again,

sorry but I didn't realise my account was still on hold.
I already managed to solve this problem with following way.
I added an script block wich combines the data in the right format, the output of the script I then put as the Attachment.

grafik
grafik

Can you share the details of the script that formats the data? I would like to send a CSV as an attachment as well.

Hello Brandon,

sure I can do that, but it's not very exciting as a also generate that csv in the same workflow, so I just combine that data.

  1. Step:
    save_csv - get's the data from preceding steps wich colleted the right data and then saving the csv in the storage
  2. Step:
    get_data - picks up the filedata from the storage again because like this it's base64
  3. Step:
    attachment_process - returns all the data from the preceding two steps and getting it into the right format
  4. Step:
    send_mail - the attachment_process.data is the whole return wich is formatted right, so it can be used as the mail attachment

I hope I could help you, if you have more questions about it or anybody else has a more elegant or better way please share your ideas.

Best regards Flo

1 Like

Thank you @FloBer !

Wanted to add this for anyone who's doing this in the future. This was the code block I used to convert the results of a query block into a base 64 format:

const dataAsCSV = queryBlockName.data

let parsedCSV = Papa.unparse(dataAsCSV)

let b64Data = btoa(parsedCSV)

let attachment = [{ data: b64Data, name: 'filename.csv', contentType: 'text/csv'}]

return attachment

The attachement variable is formatted for an SMTP attachement. Feel free to adjust as needed.