Forum Discussion

MattMelrose's avatar
MattMelrose
Qrew Member
4 years ago

link to file based of related field in parent table

Hello,

I have two tables 
Project and Documents
Project has a bunch of internal information and the documents are supplied by client / staff
Each document has a specific type and related to the project via the job number, all associated files relate correctly in a table report, but it is a lot of steps for the staff using mobile devices. 

What I am looking to do is basically have a URL field that will look at the related project files and the type of the file and provide a hyperlink for easy download / viewing. I have made a hyperlink inside of the child table that opens the correct file, but when i try to lookup that field on the parent it doesn't populate. 

EG. 
Projects tab
Project number - 12345
Documents tab - Document report:
Related Project      Type       Name     URL
12345                      Plan         file1        working link
12345                     Photo      image1   working link

I would like to be able to move that "working link" for the most recent project (in this circumstance it will be the only plan associated at this time to the project) to the main project page. 

Thanks for any help

------------------------------
Matt Melrose
------------------------------

2 Replies

  • Hi Matt,

    You can link to the file attachment uploaded to the most recently-entered child Document record, on the Project record, by using a Formula - URL field. That formula field will need a couple helper fields on the relationship to make sure the link only displays on the project when the most recently-entered document record actually has an attached file uploaded. Here's how:

    1. Create a summary field on the Projects table, called Maximum Document Record ID#. It should take the maximum value of the documents' Record ID#s.
    2. Create a lookup field on the Documents table called Project - Maximum Document Record ID#, pulling down the new summary field above.
    3. Create a Formula - Checkbox field on the Documents table called File uploaded?, to check whether your file attachment field has a file uploaded to it. The formula should be: If(Length([File]) > 0, true, false)
    4. Create one more summary field on the Projects table, called # of Files in Most Recent Document. It should count the number of related documents. Under Additional Criteria, add two lines of filters that look like this:
    -- (File uploaded?) (is equal to) (checked)
    -- (Project - Maximum Document Record ID#) (is equal to) (the value in the field) (Record ID#)
    5. Now it's time to make the Formula - URL field! You can start with this formula: If([# of Files in Most Recent Document] = 1, URLRoot() & "up/" & [_DBID_DOCUMENTS] & "/a/r" & [Maximum Document Record ID#] & "/e6/v0")

    There are two pieces you'll need to replace for your formula:

    - You'll need to replace DBID_DOCUMENTS with the table alias for your Documents table (you can find that by going to table settings, hitting advanced settings, then scrolling to the bottom of the page)

    - You'll need to replace the number in the e6 portion with the field ID of your file attachment field. So, if your file attachment field has field ID 20, then you would use e20 here.

    ------------------------------
    Brian Cafferelli
    ------------------------------
    • MattMelrose's avatar
      MattMelrose
      Qrew Member
      Thank you so much!


      ------------------------------
      Matt Melrose
      ------------------------------