Hello Community members,
Iโm trying to view a workflow pdf in the app itself. Iโve gone through the communty posts and figured that there are 2 ways of doing it - one is to create a file name/file column in the table with open file action to it. Second is to create a column for url.
Despite trying both methods several times - im getting a 404 error for method #1 and bad request for method #2. Seeking help to rectify any errors that I might be committing. PFB the details.
Method 1: Followed the method prescribed in this community post
https://community.appsheet.com/t/how-do-i-open-a-file-created-in-workflow/30630/4
Created a file type column in the table -In the workflow that creates a pdf, setting the value of file column to : /data/PurchaseOrders/2nd_Apr_202100:50:51 @ 267583bf.pdf
data/PurchaseOrders - relative folder path of generated pdf doc.
2nd_Apr_202100:50:51 @ 267583bf - file name set in create doc task of workflow (used the expression suggested in the post and disabled timestamp)
Later, added an action (external action: to open a file) and set file to [file name]. However, i get a 404 error on clicking the action button
Method 2: Followed the method prescribed by Aleksi in this community post
Created a File URl type column in the table and used the below formula for setting the URl - CONCATENATE(โhttps://www.appsheet.com/template/gettablefileurl?appName=",โOmxxxxxxx-2559xxx-21-02-23-2โ,"&tableNa... requisitionโ,"&fileName=",[File name]). [file name] - /data/PurchaseOrders/2nd_Apr_202100:50:51 @ 267583bf.pdf
also tried this formula for URL column -CONCATENATE(โhttps://www.appsheet.com/template/gettablefileurl?appName=",โOmxxxxxxx-2559xxx-21-02-23-2โ,"&tableNa... requisitionโ,"&fileName=",encodeurl[File name])
For both URL formulas, Iโm getting a โbad requestโ on clicking the URL in the app.
Would really appreciate if someone can point out the mistake. I have dedicated hours to rectify it myself but to no effect.
Thanks in advance!
CONCATENATE(โhttps://www.appsheet.com/template/gettablefileurl?appName=",ENCODEURL(โOmxxxxxxx-2559xxx-21-02-23-2โ),"&tableName=",ENCODEURL("Purchase requisitionโ),"&fileName=",ENCODEURL([File name]))
See also:
Hi Steve,
Tried the url formula that you suggestedโฆstill getting a โbad requestโ error. Any inputs?
I got nothing else.
The 404 error means the file cannot be found and is usually an issue with the pathing. If you look closely at the path in the error where it is trying to find the file and compare that to your column, App Default Path, and physical location of the file, you will likely find that there is some mismatch.
In the post you reference, I did try to spell out what I ended up with as an implementation but itโs probably hard to pick out amongst the rest of the discussion. I really should condense it and re-write it into the Tips and Tricks. If you wish to go that route, I can help.
As for the URL method, I have not used it for showing files in an app so canโt speak to it.
I compared the path in my file name column with the actual physical pathโฆit looks to be the same. 404 error doesnโt mention the path itโs searching for(neither the url suggests).
I see that you have done a neat implementation in the post message!..Would really appreciate if you could condense the solution into Tips and Tricks so that I (and future solution seekers) can follow it better. Thanks!
I see now. It use to be that the 404 error message would show a string where you could piece together the path. It no longer does that. I guess as part of the tightening of security around files.
Ok, Iโll show what I have in hopes it helps.
In the appโฆ
I have a Files view which shows files like so:
The column with the file icon is where the path of the file comes from. That column is define generically like so - note-there is no path info specified:
The applications โApp default pathโ is defined like this
In my datasheet, the file path was generated by the workflow and then stored like this:
The physical file location on Google Drive:
Putting it all together
Appsheet uses the โApp default pathโ as the starting point. It will then build your path like so:
App default path + Column defined path info + Column data
For example, I could have moved the โFilesโ portion of the path from the data stored in the sheet and placed it into the column since that is where all of the Files are being stored, and AppSheet would have calculated the same path.
A couple final tidbitsโฆ
Once the file is found, AppSheet can still locate the file EVEN AFTER RENAMING PHYSICAL FILE PATH and FILENAMEโฆAND EVAN AFTER CLEARING CACHE. I believe this is possible because Google is DocID based. I suspect AppSheet translates the path the DocID so that no matter where it physically lives on G-Drive it can still be found.
On the other hand, if after successfully finding the file, I then change the sheet path info, the file can no longer be found. Again, I suspect this is because the path does not match any previous known successful paths and AppSheet tries to resolve it from scratch. With no file found, an error is displayed.
Thanks a ton, really appreciate it! Itโs working now in the preview. However, when Iโm using the app on my phone, itโs opening the doc and immediately switching back to the detailed view. Is it because my app is not deployed?
No, should not matter if its deployed or not. I tested preview yesterday in an un-deployed app and didnโt see that issue. Let me try again now.
Preview of a generated PDF seems to be working fine on my iPhone.
Okay, I tried againโฆit starts downloading (android phone) and when it opens it re routes to the detailed app view. I guess itโs an unexpected behaviour then or some issue with my device
Definitely unexpected. I would search the community to see if anything similar has been reported - recently or in the past.
Thanks, will check it out
A client of mine has reported the same behavior when he is using the installed app on Android. However, when he uses the browser link for the app, it seems to work.
Okay got it, thanks for the input!
Hi, Iโve just joined to add my 2 cents. Iโm quite new to this and have run into the same issue regarding opening pdfs. Everything works fine on all devices except android. The pdf seems like itโs downloaded but then reverts back to the previous view.
Iโve gotten round the issue by installing the official Adobe PDF viewer app on my phone and itโs now working as it should do if I select that app.
Could this issue be down to the fact that the Google PDF Viewer was deprecated?
Will there be a fix for this as I donโt like having unnecessary apps on my phone?
Thanks.
Attn @Arthur_Rallu
It seems to be working now
I 've try this way but my result isโฆ
Unable to view the PDF File.
This is the error that is getting generated.
File location is perfect.
Screenshot_20210901-081709|230x500
User | Count |
---|---|
43 | |
28 | |
23 | |
14 | |
14 |