What is the best way to retrieve and view files in app that are generated from templates?

I use workflows to generate and send customer pdfs from templates in Google. Currently, I use the archive option to save the generated result in the default location in Google with the current timestamp to ensure file name uniqueness.

When certain record info changes, a new file is generated with the updated details and saved as a new file. I would like to be able to retrieve the history of all saved files associated with a certain record and display them in the app - as a list or gallery.

What is the easiest/best way to be able to keep a file history, view that history and still know which file is most recent to send out to customers upon need/request?

I believe the most appropriate option would be:

  • First create a table for that PDF reports, have a key column explicitly for that table, put another column for the customer records or any other you see fit to construct a REF and a file type column.
  • Create a behavior action from the parent table, that will add a row to this Reports Table. Refer to Praveen’s post here > New Action: Add a Row to a table
  • Add a second action to your workflow rule that is generating your PDFs which will trigger the behavior action above for creating a new file record each time the workflow is triggered
  • Construct the REF type column in this Reports Table and associate it with your parent table.

With this, you will be able to see all the PDF report history of the parent record as an inline view in the Detail View of any particular parent record. With the associated File Type column, you can open those PDF files directly within your app.

I believe that will be the most robust solution.

1 Like

@LeventK thank you for the quick reply!! Your suggestion is what I had in mind but I thought there might be something easier.

A follow-up question…how would you manage the filenames, remembering to maintain uniqueness? I would assume you want to generate a known name into the newly created Reports table and then use that name in the Workflow step that generates the new report file. The uniqueness part is probably the most uncertain portion for me.


Provided you don’t disable the timestamp suffix in the workflow rule, that will always maintain the unique name for the PDF files. When you enable it, AppSheet will append a system generated Timestamp in the attachment file name. The Timestamp contains the date and time at which the attachment was created. The date and time are formatted as yyyyMMdd_HHmmss_fff where fff is milliseconds. This will ensure the attachment file name is unique. For example:


Check it out more from here:

@LeventK Thanks again! I think I may not have explained my concern well enough.

If you allow the filename to be created with timestamp in the Workflow rule that generates the file from the template, there is no way to know what that filename will be beforehand because of the timestamp. So there would be no way to accurately record the filename into the Reports table for later. As far as i can tell, there also is no way to retrieve the filename created AFTER the file has been generated from the template.

So it seems A solution is:

  1. Disable Timestamp so its not added to the filename when file is generated from template.
  2. Manually create the filename (can include Now() to add timestamp)
  3. Store the created filename into the main record as say “Current Filename”.
  4. As discussed before, use Action from Workflow to add new row to Reports table with filename as “Current Filename”.
  5. Generate file from template with name as “Current Filename”.

While these steps could add the correct filename to the Reports table for viewing in the app, the potential issue with this approach is that should the file generation fail (bad template, connection problem, etc), the app will reflect a file that does not exist.

It is better to create the file first and then store the filename into the data afterwards. But I don’t see a way that can be accomplished. In the end, the risk of an issue is minimal and acceptable.

So, what are your thoughts? Is there a more minimal approach?

For sure, it could be very good to have a system variable or function i.e. IFERROR(“Workflow_Rule_Name”) which can return a boolean value, so that we could know if the result of the workflow is successfull or not but unfortunately we don’t have it. So I believe this option is the best to achieve the result. There is a [_ATTACHMENTFILENAME] built-in variable to retrieve the name, but it can only be used in a workflow body.

Hmmm. I was not aware of that built in variable. Since we now have multi-action Workflows, is the scope of that variable within the ENTIRE Workflow body or or just that single Action of the Workflow. In other words, if I generate the file as the first step in a Workflow and that sets [_ATTACHMENTFILENAME], will that variable value pass on to an Action called as the second step of the Workflow - where I could collect it and save it to table?

I suspect not but I’ll play and see.

One way is if you don’t use the system generated timestamp. One way is a version number in your file name. Of course it depends if there is lot of users and then the version number could be twice.