Hi, I am attempting to attach a csv file stored in Retool Storage.
The error I am receiving is: "Error evaluating query2: Use File Input component to upload a file and ensure file is uploaded before query is fired."
The code I am using in the fx field is:
[{data: {{query3.data.base64data}}, name: 'FlightLogReport.csv', contentType: 'csv' }]
Even tried steps in : Error attach data to Retool Email in workflow - #4 by FloBer
Code:
return [{
"name": query3.data.name,
"type": query3.data.type,
"sizeByte": query3.data.sizeBytes,
"base64Data": query3.data.base64Data
}]
Get the following 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:538,isPreview:false,resourceType:retoolEmail,lastReceivedFromResourceAt:1746750373590} |
data |
{} |
Having some success using this:
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
Getting the right syntax is vital for the attachment JSON. For anyone else, this is what finally worked for me:
return [{
"data": get_FileProperties.data.base64Data,
"name": get_FileProperties.data.name,
"contentType": 'text/csv'
}]
Since learning this I have now constructed a workflow to loop through all flight data records and email them to all our pilots using the retool workflow component to include a report as well as a csv attachment of their flights for the month.
3 Likes
Thanks for sharing this update, @Augustine_Whitehouse! 
1 Like