URL Formula to open file attachment

  • 1
  • 1
  • Question
  • Updated 11 months ago
  • Answered

Ok - I may be missing something easy here, but I need help.


I have a file attachement field that may or may not have a pdf attached.  Is it possible to have a URL Formula (so I can have a button) that will show up only IF there is an attachment and the URL would be a link to that attachment?


If it's not possible to have it show up only if there is an attachment - what would the formula be to link to that field either way?  - I know there is the link that is the file name, but I really just want it to show up as a button.


Thanks!

Photo of Stephanie

Stephanie

  • 10 Points

Posted 3 years ago

  • 1
  • 1
Photo of Keith

Keith, Champion

  • 1,090 Points 1k badge 2x thumb
try this....assuming the name of the file attachment field is Document

create a new field, type should be formula text - check off "allow html"

if ([Document]>"", "<a href=\"" &URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#]& "/e999\"target=_blank\">" & [Document]& "</a>","")



change the 999 in e999 to be the field id of the Document field



Keith
Photo of Juan

Juan

  • 476 Points 250 badge 2x thumb
Hi Keith,

When I do this, the document downloads and the user still has to click the downloaded file on the bottom left of their screen in order to view the document.

Functionality-wise, there is no difference between this approach and the link that Quick Base creates when adding a field of type "File Attachment" .

Is there no way to make it so that the document opens instantly when clicking the link, therefore eliminating that second click?

Thanks in advance.
Photo of Leo

Leo

  • 44 Points
Hi Keith,
This works perfect when is empty, but when I have a file the link shows but with the formula. Is there any way for the formula not to show?
Photo of Stephanie

Stephanie

  • 10 Points
Beautiful! Works perfectly - is there any way to get it to show up as a button?  Thank you!!
Photo of Keith

Keith, Champion

  • 1,090 Points 1k badge 2x thumb
change the field type to formula URL and check off display as a button
Photo of Stephanie

Stephanie

  • 10 Points
Unfortunately when I do that, the URL quits working.... I didn't change anything else at all!
would it be possible/easier to use an icon?
Photo of Gina

Gina

  • 0 Points
[mention://553 @keithj16] This is working for me, but when I try to pull this record into a child record it won't work because it references the child table DBID, Record Id and field ID. Is there a way to change that to reference the parent ID within the formula?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,834 Points 20k badge 2x thumb
@Gina: I noticed you had a WebMention to Keith. I am curious how you inserted that mention or what program you used to do it.
Photo of Keith

Keith, Champion

  • 1,090 Points 1k badge 2x thumb
yes..just change dbid() to the actual id of the master table...
2 ways.....1 hardcode the master table id or 2 use the master tables alias name
1.  "up/bbbbbbbbb/a/r"
2.  "up/" & [_DBID_MASTERTABLE] & "/a/r"
Photo of Keith

Keith, Champion

  • 1,090 Points 1k badge 2x thumb
oh... and use the Reference field from the Master table relationship instead of [record id#]
change [Record ID#] to [Related Master]
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,142 Points 3k badge 2x thumb
I may have 4 different documents in the table.  Is it possible to open one in the dashboard using a 4 button? 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,438 Points 50k badge 2x thumb
Yes, just make 4 Dashboard buttons, each will be a URL type and you paste in the URL link you need once you have either exposed the URL in the formula field or else copy the URL from your Browser when looking at the result of clicking the button and copy and paste it into the URL for the button.
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,142 Points 3k badge 2x thumb
Thanks Mark.  I think you created one button for me (and I can see the URL in this button). If I were to create a new button, where do I get the URL.  I am somewhat confused when you say 'expose the URL'.     
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,438 Points 50k badge 2x thumb
By expose he URL, I simply mean to remove the label of the button and also to uncheck "Show as Button". That way you will see the URL and be able to copy and then paste it.
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,142 Points 3k badge 2x thumb
Thanks I got it.