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

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.

where did you store the “current invoice” data? at the parent table or the pdf report table?

when i test my file name function:

substitute(concatenate([פקע], “-”, day(today()), “-”, index(list(“01”, “02”, “03”, “04”, “05”, “06”, “07”, “08”, “09”, “10”, “11”, “12”), month(today())), “-”, year(today()), “-”, timenow()), “:”,"-")

it is working.

also when i test my file location function it is ok:

concatenate(“appsheet/data/qctest-310438/reports/”,[פקע],"/",pdfreports[name] , “.pdf” )

but at the data table i get this: “appsheet/data/qctest-310438/reports/PRD00125638/.pdf”

what am i doing wrong?
both lines are executed at the action.

If your saving of the file is going to the folder you wish and you can open the file, then you do not need to look at the Save PDF File workflow. That part is good.

Could you provide screenshots of the following four things?

  1. Your “Default app folder” setting - found under Info->Properties->App Properties.
  2. Column definition for the file column.
  3. Your column info captured in the sheet.
  4. The physical location of the file in your datasource - including path info.

From that we can piece together where the path construction is mis-behaving.

  1. Column definition for the file column:
    Image/File folder path: CONCATENATE(“reports/”,[פקע])

App formula: concatenate(“reports/”,[פקע], “/”, “changereport”,".pdf" )

3.Your column info captured in the sheet: reports/Prd43/changereport.pdf

  1. The physical location of the file in your datasource - including path info:
    the file is in google drive
    appsheet/data/qctest-310438/reports/

Images are 100% better to accurately convey info.

Reading what you typed, it seems you may have the “reports” folder introduced twice.

EDIT: Sent this before I intended.

You can confirm in the error message screen what path it is trying to use. Look it over carefully to find the full path it is looking at.

I would try removing altogether the path info in the column definition.

i am limited by the site rules to attach more than one image…
sorry

Understood!

According to what you posted you have the file path defined in the column as “reports/Prd43” but if you are also including it in the filename saved in the sheet as “reports/Prd43/changereport.pdf” then the app is likely looking for a file with this path:

“appsheet/data/qctest-310438/reports/Prd43/reports/Prd43/changereport.pdf”

note that “reports/Prd43” is listed twice. You can confirm this by inspecting the error message screen you get for the path.

To fix, simply remove the folder path definition in the column since you are already building the full file path into whats saved in the sheet.

ONE OTHER NOTE: in #4 you mentioned the path is “appsheet/data/qctest-310438/reports/” but didn’t include “Prd43” if your files are truly being stored inside of the “reports” folder, then you’ll need to remove the “Prd43” portion that is written to the sheet.

2 Likes

hi again

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

1 Like

Hi,

This is really useful, but I wonder; would you know of a way to display the pdf directly within the app detail view?

I do not believe that is possible at the moment.

But I’m curious about your use case.

Are you wanting to be able to view the entire document in this manner?

I could see the benefit if there was some sort of thumbnail displayed to distinguish one doc from another when there are multiple

That is a shame, think it will be really useful and hope that it would behave in a similar way of when an image is captured via camera, maybe not immediately as the app will need time to create the document.
Is there a way of converting the pdf to a jpg or similar, and do you think we could work around this and display the converted pdf?

Don’t forget about multi-page PDF’s!

I am not familiar with a way to convert PDF to JPG. But seems like there could be something. It would need to be something outside of AppSheet. If you can get the doc converted to an image then you certainly can display it as an image in the app.

Are you just trying to make the user workflow simpler without the extra taps to view the document?

Will have a look around and investigate.
It would be nice to have the doc as an image within but having the extra taps to display the pdf isn’t too taxing for the user.

Another thing, the pdf location is saved within my table and can be clicked to view but the clickable text is just what the cell contains within the table.

image

How would I make this look better?
Maybe just show ‘Click here to view’ or something similar.

If you scroll up on this thread and look at my post on Sep 19, I gave some images on how I display my files. I create an action used in a Deck View to show a list of files and then select the one I want. If there is only a single file, this action could instead just open that file.

What view are you using to get to the Detail view?

As soon as I clicked reply I knew the answer to the question already.
I’ve created an action and it’s viewed inline within the detail which is connected via a table.
I’m sure I’ve read somewhere that you can add the actions within the row of a table which may be a better option for me.

Actually, by default you already have a system generated Inline action created. If you simply show the PDF column in the table, the action will be displayed instead of the file path text.

In the table below, the solid icon is the system action. The other is my custom action.
Screen Shot 2020-03-27 at 1.48.10 PM

To create my custom Inline Action, I created a Virtual Column, defined it as Color type and then set the color = " " (a single space). Copy the system action, rename it and set the attached column to the Virtual Column.

In Detail View, Custom Inline Action shows with no text
Screen Shot 2020-03-27 at 1.51.35 PM

Nice!
Thanks!

@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 :slight_smile:

2 Likes