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?

1 76 10.8K
76 REPLIES 76

@Aleski - I was indeed referring to column of type File. I read this:

"Constructing an Attachment File URL

"YourAttachmentFileName" must specify the Attachment Folder Name followed by the Archive File Name. Omit the Default app folder name. Calls to โ€œwww.appsheet.com/template/getappfileurlโ€ automatically prepend the Default app folder name."

I took this to mean that I can use my column File type and AppSheet will add the necessary bits for the URL.

This also leads me to a questionโ€ฆWhat is expected to be written in terms of path + filename+ extension to the column of File Type? When I write only the โ€œfilename.pdfโ€, and then try to view that file, I get an error that file cannot be found (see pic below).

Only when I update the File column text to โ€œappsheet/data/ServiceInsightDemo-526414/Files/Estimate_p7fudBEC_2019820_10_43_33.pdfโ€, is the file able to be viewed from the app. Bu this is WITH the default app folder which seems to contradict the paragraph above.

The other puzzling thing is that in the error it seems it is trying to use appName variable = โ€œServiceInsightBase-526414โ€ to create the URL. I have the Default App Folder as โ€œ/appsheet/data/ServiceInsightDemo-526414โ€. The files are written to the Default App Folder as expected. But even copying files to a folder for appName (under appsheet/data), the file is not found.

@WillowMobileSystems
I had the same problem. Then I found the reason: My Table and my file folder were outside the App folder. That happens when you create a Sheet, then an App an then forget to copy the sheet into the App folder

Hi Fabian

Iโ€™m trying to troubleshoot why I canโ€™t open the file I generate in the app and found your comment.

Is it really required to have the spreadsheet inside the app folder?
I couldnโ€™t find this written anywhere in the Appsheet documentation

Update: Unbelievableโ€ฆ This has solved my problem. Thanks!!!

@Steve, can we get this documented somewhere? (unless I missed it)โ€ฆ

Yes, at least in some cases, I believe it is correct that currently the file/item folder path is based on the location of the sheet. I have not played with this in a dedicated fashion to determine if in all cases this holds true. And what happens when its a database?

However, I believe this to be a flaw. It is my strong opinion that all pathing should be based on the Default app path set in the app regardless of where the sheet is located. I think I opened a Feature Request for this a long time ago. Maybe its time to find it, dust it off and resurrect it?

Yes please have my upvote. It makes sense to think itโ€™ll default relative paths from appfolder and not the spreadsheet location. This not only makes it breaking change when moving spreadsheet, but it is also very unintutive, what if you have sheet on one data source and image on other.

I wish to add my vote to this behaviour. Does AppSheet have a feature request for this?

Adding @praveen for more insight on this

Hereโ€™s an answer from Praveen on this issue:

Iโ€™m really struggling with this one! Can you send a screenshot of your Action set up to create the filename?

Also, having created a specific folder for these pdfโ€™s to go into, it has decided to put them in another folder which I had to dig around and find as it had created multiple layers of folders.

Sure! As I mentioned above i create the filename in 2 parts.

  1. I save into a column the file prefix name. This allows me to use the same name for the multiple steps I have AND include a TimeStamp to ensure uniqueness:

The below expression creates a name like "Invoice_c98a86fb_20190914_11_38_01"

Note the use of SUBSTITUTE(). I found that the Workflow steps replace the โ€œ:โ€ in the time with slashes. This is why you are seeing layers of folders most likely.

  1. When I add the file path+name to the table, I use the expression below to build this complete name:

In this expression, the text โ€œappsheet/data/ServiceInsightDemo-526414/โ€ is based on your App Default Path. When writing the actual files, the app default path is used. However, when the files are retrieved, the default path is NOT used so you have to include in the built file path+name.

2X_8_84d8c5c90f4c81b9548853a2a3e012d7a873c350.png

Digest this and let me know what further questions you have.

hi

i followed your instructions on how to name the file
i cant seem to open the file from the app.
do i need to make the column a url? a file?
i get an error when i try to open it

For a file, the column should be defined as type โ€œFileโ€.

First, make sure you can open the physical file from the source.

Next, make sure you have the path to the file properly captured. In the app, you will have a Default App Path property. The application will start from there to try and find the file. Any additional folders involved will need to be included in the sheet File column.

For example, I have a Default App Path property defined as

"/appsheet/data/ServiceInsightDemo-526414"

From that location, my files are physically stored in a folder named โ€œFilesโ€ AND then another folder that is the name of the Order # of the record the file is created for. So if that Order # = โ€œ20200115Eโ€ then the remaining folder path would be:

"Files/20200115E/"

If my filename is โ€œInvoice_20200115E_20200115_22_46_32.pdfโ€ then I MUST have in my sheet data in the File column the value of:

/Files/20200115E/Invoice_20200115E_20200115_22_46_32.pdf


NOTE: I may have been able to place the "Files/20200115E/"folder info in the AppSheet column definition and then only have the filename itself in the sheet. I created this before I realized the folder property was there. I will at some point make that change as it will save on amount of data in sheet which will improve performance. Every little bit helps!!

This works perfectly. Thank you so much @WillowMobileSystems .
It seemed much more complicated than what it actually was.

thanx for the quick reply

i have the file creation action, and i get the file location information in the colomn.
but when i click on it i get an error message:
" 404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable."

the reports are stored in : appsheet/data/qctest-310438/PRD00125636/PRD00125636.pdf
but my google sheet is in a different library. i assume that is the reason that i cant open the fileโ€ฆ

what do i need to do in order to get the file to open when it is in a different location?

Are you using concat expression to construct URL dynamically?
Use encodeurl() expression within that formula.

hi

  1. i have a name column with formula:

substitute(concatenate([ืคืงืข], โ€œ-โ€, day(today()), โ€œ-โ€, index(list(โ€œ01โ€, โ€œ02โ€, โ€œ03โ€, โ€œ04โ€, โ€œ05โ€, โ€œ06โ€, โ€œ07โ€, โ€œ08โ€, โ€œ09โ€, โ€œ10โ€, โ€œ11โ€, โ€œ12โ€), month(today())), โ€œ-โ€, year(today()), โ€œ-โ€, timenow()), โ€œ:โ€,"-")

to create a unique file name.

  1. i then have an action Data: add a new row to another table using values from this row (my main product table). with a formula for the file path:

concatenate(โ€œappsheet/data/qctest-310438/reports/โ€,[ืคืงืข],"/",pdfreports[name], โ€œ.pdfโ€)

  1. than i use a work flow that executes:
    3.1 change data - executes the action in step 2.
    3.2 saves a PDF file

    3.3 then i send an email with attachment.
  2. i have the pdfreports table referencing the main product table using the key: [ืคืงืข]
  3. i have a deck view in the ux for the pdfreports table
  4. when i try to open the file i get an error message

File path seems to have issue.
pdfreports[name] should return the โ€œlistโ€ I suppose. The file path should NOT be list type.
My suggestion is just test it step by step. First, you delete file path and bring it back to default.
Then re construct the url.
in your case, own file path name make the things complicated, so do a step by step approach to debug.

hi again

just wanted to say thank you all for the great help, i got it working finally!

Hu Guys, how are you doing ?

Doing some research here on the community I came to this awesome topic.

I was wondering if I could count on you to help me with Get Url formula.

Firstly I used the formula suggested on this link https://help.appsheet.com/en/articles/2744751-email-attachment-file-archiving and It worked. Then for some reason the suggested formula stopped running.

Please find on this link a demo video to better show the problems I am facing https://drive.google.com/open?id=1KwL47Gwzsccp_kWd3c2jYPFaXiovnaHa&authuser=costa%40costaevalle.com&...

On this video the formula was working https://drive.google.com/open?id=1L0kAiJv8ETAW5yKtkq9kCIGGnsd_iVV9&authuser=costa%40costaevalle.com&...

Kind regards,

Hey Guys, I am trying to make my emailed attachment pdf to be aaccessible from the link in the app. I am trying to understand the basics of linking to one specific file on my google drive for now. I canโ€™t get it to work. The file path in the google drive is mydrive/appsheet/data/attachments/SITECH_723242305_V15.pdf
I have a column that is a FILE type. My initial value is URL to the file which looks like this.

I get 404 file not found. What am I doing wrong?

Thanks,

Firstly, the paths of your stated G-Drive location and that used in the Initial value are not the same at all.

Second, is this a file that is generated from a workflow? If so, it my understanding, that the storage path of the file is based on the location of your data sheet.

I will guess that your sheet is stored at mydrive/appsheet/data. When an email workflow is run and no path is specified for saving of the generated file, AppSheet will use the folder โ€œAttachmentsโ€ by default (if I remember correctly). This means any generated files by this workflow will be stored at "mydrive/appsheet/data/attachments"

In the app, when attempting to specify the location of the stored file, you need only specify the path from the sheet root folder which in the example above is the "data" folder.

So you would want to use the path "/attachments/SITECH_723242305_V15.pdf" in your File column.

Thanks for the tip John. However my sheet is actually in the root directory of my g drive. But you are correct the attachements are stored in appsheet/data/mynewapp-505828/Attachments.I tryied this link as you suggested

/www.appsheet.com/template/Attachments/SITECH_723242305_V15.pdf"
didnโ€™t work

I have seen a conversation above that the sheet needs to be in the myNewApp-50582 directory for the links to work. I moved it and it broke everything. I have pictures and signatures and barcodes in that sheet. they all started acting wonky. And by wonky I mean not displaying randomly. Moving back didnโ€™t fix it. So I had to delete the source in appsheet move he sheet and reconstract everything. Sorry I side tracked.

I also tryied using this expression

http://www.appsheet.com/template/appsheet/data/appName=โ€œMyNewApp-505828โ€&fileName=Encodeurl(โ€œAttachm..."

and i just get this in my browser adress
https://www.appsheet.com/template/appsheet/data/appName=MyNewApp-505828&fileName=ENCODEURL(

So my syntax is wrong i just dont know where?

Hi @SITECH_Mid-Canada I think you use a Workflow to send a PDF as an E-Mail and archive it to your Google Drive.
So your workflow setting includes โ€œAttachAndArchiveโ€.
In โ€œAttachment Folder Pathโ€ you can set your own path. But: this will always be located in the folder where your google sheet is located.
Out of the box it will save your PDF files to:
"mydrive/appsheet/data/YourApp/attachments"
I would also recomend to disable Timestamp.
3X_0_5_05252e33f3522566b0343e25d1fa10e6def1cbb7.png

Everything you need to know is written in this help article:

You are exactly right. I generate a PDF from a template and it is stored in a default directory. What I am trying to do next is put a link to this PDF directly into my sheet. It is usefull if I want to say print the pdf from the app without having to look for it in the emails.

Please see at the bottom of this article
โ€œConstructing an Attachment File URLโ€

If you are using Microsoft instead of Google you can easily use Power Automate to save the name of the archived file into an Excel table which can be viewed in App.

  1. Create a table to hold list of reports - bring into App

3 columns
Report Date,
Report Name,
Report Link (=Hyperlink(Report Name)). This is a an Excel formula

  1. Save and Archive using workflow.

  2. Use MS Power Automate to create a workflow
    When a file arrives in specified folder
    Get file info
    Add a row to Excel table with file info

    This runs automatically every time a file arrives in specified folder so Excel table is always up to date

Thanks I will consider this as my fall back plan if I cant figure out this โ€œlinkโ€ thing.

Does this only work if you are building/generating the pdf in/through the app? Or can I use this to search a drive and find a pdf with CONTAINS?

Hi @Tiger would that be a solution for you?

https://help.appsheet.com/en/articles/4865398-folder-data-source-the-essentials

Sorry - I was out for a while. Thank you so much for the help. Let me look at this and seeโ€ฆ

It seems that what @Fabian has suggested is the way to go IF your documents are stored in a Google Drive folder. it appears that is the only Folder source that is supported at the moment.

I donโ€™t see โ€œDocuments on Google Driveโ€ anywhere. What about Onedrive? Is that an option?

And - btw - no the documents are NOT stored in ANY cloud. They are in a shared drive in my companies server - this is where all employees dump that info. They want me to get it (pdf) and allow the user to print that pdf - inside the folder of the shared drive.

At the moment, you cannot yet use an AppSheet app to select files in folders on a local network server to view, print or attach to an email. They would have to have been added into the app first.

AppSheet seems to be moving in that direction by allowing such a search and find against Google folders. By the way, the screenshot I included is presented after clicking on the Add Table button.

If it is necessary to gain access to those files from the AppSheet App, is there anyway they could be moved to Google or a copy placed on Google where the app can gain access to it?

If not, then Iโ€™ll have to rely on others to respond with any know workarounds.

I am doing JUST that - moving to Google. Only problem is - they are updated daily. Meaning - new invoices are loaded daily. So looks like ill be copy and moving daily. Thanks for the helpโ€ฆ

Question - I loaded a test file/folder. How Do I print pdfs from it?
I have files inside folders - It did not drill down - is it suppose to?

Did you try applying the suggestions from @Fabian 's post above? I havenโ€™t tried it out yet myself.

Let me go back and look. Thanksโ€ฆ

Top Labels in this Space