PDF does not download the file Updated

Hei
Bronze 5
Bronze 5

Hello everyone, I have two buttons; one that generates the PDF and another that downloads it, all perfect on the first try, but when I make some modifications to the list and generate the PDF it is updated in Drive, but when I click download does not download the file Updated, download it the first version.

Do you know if I'm doing something wrong?

Thanks!

2022-01-29.png

Solved Solved
0 18 1,726
2 ACCEPTED SOLUTIONS

There's only one file in your Drive. Perhaps as John said AppSeet is not recognizing that the file has been updated. Perhaps the old file is cached and since you are using the same name it is brought from your browser's cache instead of downloading it again from Drive. Perhaps it is another issue. 

It is best to generate a new filename with every new file generation. 

View solution in original post

AppSheet caches all files and images. You cannot replace a file at the data source with the expectation that the replacement will be served rather than the original--it will not. You must change the file name.

View solution in original post

18 REPLIES 18

When you change app data and regenerate, it is not actually updating the first PDF.  A new PDF is being generated.  YOu need to make sure the column [File] is being updated with the NEW PDF file info.

By the way, it looks like your Download button is simply opening the PDF file which I assume your PDF button is doing as well.  Why have two buttons doing the same thing?  The actual download option is embedded in the PDF viewer.  You only need the ability to open the PDF then a user can choose to download if they wish. 

 

Hi WillowMobileSys, How can I do to make sure the column [File] is being updated with the NEW PDF file info? 

2022-05-20 (4).png2022-05-20 (5).png

I see.  You are using the row key for the filename.  When you re-generate the PDF, you use the same filename and the expectation is that the file is overwritten.  

However, in Google Drive, files are not actually overwritten, as you point out, there is a version history kept.  The problem you are facing is that when attempting to "download" the file, you are getting the older version of the file and NOT the newer version.

It is my understanding, that when accessing a file, you will always get the most current version.  

Larger files may take some time before they are available for access on GDrive but your files are small so should be available almost instantaneously.   So I am left with one possible explanation. 

Maybe AppSheet is recognizing the file already exists and is NOT writing the updated file to GDrive.    Have you checked the logs for any such errors?

Hi, it does not generate any error. I think it is a compatibility problem between GDrive and AppSheet, I have already found three people in other forums who have the same problem, and none have found the solution.

Anyway, thanks for taking the time to read my question. Have a good one!

My experience is that even small files but with images take some time to be available in Drive after sync finishes. You can see the file inDrive but you keep getting a โ€œbad requestโ€ (not โ€œfile not foundโ€) error while attempting to open from the app, for 15-20 seconds or so. 

Iโ€™d say update your filename with a time stamp, and have a separate script to remove older files automatically if you wish.  

Hi, I updated my file name with a timestamp, but it was worse there I got an error when downloading the PDF because it can't find it.

As for the scripts, I don't know what exactly that is, I'm not a programmer nor do I have any knowledge, I made my app with a lot of tutorials LOL.

Thanks for answering

The issue with using the Timestamp is that you can no longer "deduce" what the filename might be in order to write it to the File column in your app.  You will have no idea what the actual timestamp value used in the creation of the filename is.

Unfortunately, at least as far as I know, AppSheet doesn't provide any way to easily retrieve the filename used for the file and store that into a table column.  There are a couple of things you can do:

1)  Create your own filename in the app,  write the file path and filename to the column in your app and then generate the PDF using your custom filename.

2)  AppSheet does have a relatively new feature to use a Google Drive folder as a source for a data table in the app.  When your PDF's are written to the Google Drive, they go into a default or specified folder.  You can create a table on that folder and basically perform any operations you would for any other table - including deleting  items.  So you could create a Ref to the file row and access the file that way.  This allows for multiple file rows and you would setup your Ref column to only access the latest one.

Timestamp: NOW()

Filename: [key] & [Timestamp] & โ€œ.pdfโ€



@Joseph_Seddik wrote:

Timestamp: NOW()

Filename: [key] & [Timestamp] & โ€œ.pdfโ€


Correct!  That is similar to what I was referring to in option one. 

However, unless something has changed, you can't just tack on NOW().   The colons are automatically replaced with a "/", so when attempting to access the file, the systems thinks in resides in extra non-existent folders.

To correct for this, use the SUBSTITUTE() function to replace the colons.  in the example below, I replace them with "_":

SUBSTITUTE((CONCATENATE(IF([Paid?] = "Yes", "PaidInvoice_", "Invoice_"), [Order #], "_", YEAR(TODAY()), 
INDEX(LIST("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"),MONTH(TODAY())),
DAY(TODAY()), "_", TIMENOW())), ":", "_")

 The resulting filename will look like this:

Invoice_f3d7e048_20220118_12_46_30

 


@WillowMobileSys wrote:

To correct for this, use the SUBSTITUTE() function to replace the colons.  in the example below, I replace them with "_":

SUBSTITUTE((CONCATENATE(IF([Paid?] = "Yes", "PaidInvoice_", "Invoice_"), [Order #], "_", YEAR(TODAY()), 
INDEX(LIST("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"),MONTH(TODAY())),
DAY(TODAY()), "_", TIMENOW())), ":", "_")

 The resulting filename will look like this:

Invoice_f3d7e048_20220118_12_46_30

CONCATENATE(
  IFS([Paid?], "Paid"),
  "Invoice_",
  [Order #],
  TEXT(NOW(), "_YYYYMMDD_HH_MM_SS")
)

@Steve  Awesome!  I always learn from your expression simplifications. 

I wrote this expression many years ago and either the TEXT function was not yet available or I just didn't know about it yet.  

Hi Steve, thanks to the comments of WillowMobileSys and Joseph_Seddik, I am doing that, but the problem I am facing is that when attempting to download the file, I am getting the older version of the file and NOT the new version.

Regards. 1.png2.png3.png4.png5.png

AppSheet caches all files and images. You cannot replace a file at the data source with the expectation that the replacement will be served rather than the original--it will not. You must change the file name.

Thank you !

I need clarification on "replace a file at the data source". I have an Appsheet automation that is updating the PDF (Timestamp Disabled) and it's bringing back the wrong version. Even when I go into google drive and delete the prior versions, it still brings back the earlier version. There is no logical link between the Automation File Name Prefix and Table Column where File Name is stored. Would be nice to have an override for Appsheet cached files in certain circumstances. I guess I have to code a version number or timestamp of some sort on the filename.

Please start a new topic for help with this.

Thanks much John. I didn't know about this behavior of replacing colons with slashes; luckily I've been preemptively formatting my timestamps with TEXT() ๐Ÿ™‚ 

There's only one file in your Drive. Perhaps as John said AppSeet is not recognizing that the file has been updated. Perhaps the old file is cached and since you are using the same name it is brought from your browser's cache instead of downloading it again from Drive. Perhaps it is another issue. 

It is best to generate a new filename with every new file generation. 

Top Labels in this Space