Forum Discussion

JoeHargrave's avatar
JoeHargrave
Qrew Trainee
3 days ago

Quickbase Native File Attachment Question

I think this is a simple thing, but I've been struggling with it for a while, so I thought I'd ask the community.  I have a direct quickbase file attachment on a form.  I want to only show that in edit mode (easy), then I want a button that will download that file when in view mode.  I've tried formula URL and Formula Rich Text, but I can't get the syntax right I guess, because I continually get a 400 error.  Can someone tell me how to accomplish this please?

4 Replies

  • Nevermind - I finally figure it out.  I don't see a way to delete the original post, but I got it covered.  

  • Would you mind posting your solution? Might help others if they come across your question. You could then mark your response as the solution.

    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend

      If you wanted to have a field which looks like the file attachment field, that just downloads the file you can make this Rich Text formula field.  It's also a great way to "lookup" a file attachment to a child table.  Of course this is not really looking up the actual file attachment field but instead it's looking up a link that when you click, it will behave as a file attachment field and download the attachment. 

      There is also also slightly different syntax if the file attachment is is an image, and you want to display the image directly on the form or be able to look up the image down to a child table. 

      In this example the file attachment field is [Spec Sheet] and it is field ID# 12.

      var text Words = [Spec Sheet];
      var text URL = URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e12/v0";  // replace the 12 with the field ID#.

      "<a href=" & $URL & ">" & $Words & "</a>"

    • JoeHargrave's avatar
      JoeHargrave
      Qrew Trainee

      Absolutely Ember, not a problem.  For the record though, Mark answered this and generally speaking, I'd trust his answer over mine.  :)   Below is the code for the button I got to work.  This is basically a download only button, set to show in 'view' mode only, so our clients can easily download their documentation.  It's downloading the document attached to the specific file attachment field id number.  My button has some styling parameters in it as well, which can be changed or ignored.  In this case, the field id number for the attachment field (where we attach the document internally) is 367.  Additionally, it was important to me that the button NOT show up at all if there is nothing attached.  We have several of these fields, but not every customer has every attachment that is relevant to them.  This one is for a base contract, and the button simply says "Download Your Contract".

      If(
        [Contract - File Attachment] <> "",
        "<a \n     class='Vibrant' \n     href='" & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e367/v0' \n     target='_blank' \n     style='\n       display: block;\n       width: 100%;\n       text-align: center;\n       border: 1px solid black;\n       border-radius: 24px;\n       color: #000000;\n       background: #a3ccc8;\n       padding: 10px 16px;\n       text-decoration: none;\n       font-family: sans-serif;\n     '>\n     Download Your Contract\n   </a>"
      )