I have this working in my app now. You may need to play around with paths and filename creation to get it right and understand what is going on.
When I generate a file from template, I send it out in a Workflow step as an attachment only on an email. I use a second step to generate it again and save the file. This seems to give me better control over the file name (though I don’t like generating a doc twice).
To start, I built an Action that first creates the filename prefix and saves it in a column that I later use when creating the file (see Workflow step below). This allows me control to use the SAME filename used in both the attachment as well as the writing of the file while still using a timestamp that ensures no dup file names.
In the Workflow step that creates an attachment to an email, I only need to give the filename prefix since it doesn’t archive the file.
The path and filename are actually generated in the Save File Workflow step in 4 parts:
- The default app path setting
- File Folder path set in the Workflow
- File name prefix which uses my saved filename created by the Action.
- File suffix determined by the HTTP Content Type setting.
I wanted to take this a step further by keeping a file history of each file sent out. To do that I record the path and filename of the written file so I can retrieve it later. I created a table and use an Action to add a new record that saves some info and re-creates the filename utilizing the previously saved filename prefix column and known defaults. The table looks like this:
Then in my app I have a deck view for Orders with a button to navigate to the file list. Its the doc icon with magnifying glass.
Tapping the button brings me to this screen:
Tapping on one of the file records opens the file. The file is opened in a browser window and looks like the below on a desktop:
I hope this helps! Feel free to reach out if you have questions.