Forum Discussion

MrunaliKadam's avatar
MrunaliKadam
Qrew Trainee
4 years ago

Include/add pdf flyer on the form

Hi,

I've created a pdf which has instructions for user so they can successfully submit the form. Now looking for solution/ideas to include this pdf flyer on the form. 

Please advise.

------------------------------
Mrunali Kadam
------------------------------

12 Replies

  • Also super important.  You need to check the box on the file attachment field properties to allow viewing the document without logging in.  That is because google needs to pull the document to display it.

  • I have never never tested this on new forms so it may not work. Can you just quickly mock up the bare minimum on a legacy form style and let me know if it works.

  • Hey Mark,

    Been away for a few days.  I built everything shown as above but it shows up as no preview available.  The "Attachment Type" is that supposed to be a text formula? 

    I did notice that the URL formula that was posted has the "If([Attachment Type 1]="File"", but we named the field "Attachment Type," I just assumed that was a typo as when I add the 1 it doesn't recognize the field. 

    The Attachment type does say File and the code page does seem to be pointing to the right place but its not showing up. 

    Any thoughts? 

    Thanks
    Jen

  • This code was probably created by the famous Kirk Trachy, a sales engineer at Quickbase who is now retired.

    Did you make the code page exactly the way I posted it?

    Did you make the URL field exactly like this?

    Create the URL field type for the form. Type = URL . Set as iframe.  Set  800 by 800 size.

    If([Attachment Type 1]="File",

    URLRoot()&"db/"&AppID()&"?a=dbpage&pagename=iframe.html&rid="&[Record ID#]
    &"&tabledbid="&Dbid()
    &"&myurlroot="&URLRoot()
    &"&fileattachmentfid=9")

     

    The only thing you should change in the above code would be to change the 9 to the field ID in your Table, which holds the file attachment  

     

     

  • Hey Mark, 

    I have a file attachment field that we are uploading PDF's to and I am trying to view it on the new forms.  I was trying to use your solution but I can't figure out how to use the quickbase file field instead of the googledoc in your example.  I got the code page to work with one file url but I need it to be dynamic.  

    I am using your code page formula and other fields in the example, and I am attempting to update the const src to be the Quickbase file attachment field?  Is that the right line to update? , I couldn't understand your last comment.  This is the code I got to work for one file attachment but I need it to be dynamic and not just one record ID.  

    const src = "https://realm.quickbase.com/up/tableID/a/r/e/v0/url=+ myurlroot + "/up/" + tabledbid + "/a/r" + rid + "/e" + fileattachmentfid + "/v0&embedded=true";

    Thanks

    Jennifer

    • MrunaliKadam's avatar
      MrunaliKadam
      Qrew Trainee
      Want to embed the pdf..

      ------------------------------
      Mrunali Kadam
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        This should get you started. It my own cheat notes which you can adapt.


        Step 1.

        Create a Code page called iframe.html
        <html>
        <head><title></title></head>
        <body>

        <iframe id="kirk" style="height:100%;width:100%;border:none;overflow: scroll;"></iframe>

        <script>

            const urlParams = new URLSearchParams(window.location.search);
            const rid = urlParams.get('rid');
            const tabledbid = urlParams.get('tabledbid');
            const myurlroot = urlParams.get('myurlroot');
            const fileattachmentfid = urlParams.get('fileattachmentfid');
            const src = "https://docs.google.com/gview?url=" + myurlroot + "/up/" + tabledbid + "/a/r" + rid + "/e" + fileattachmentfid + "/v0&embedded=true"; 

        document.getElementById("kirk").src = src

        </script>
        </body>
        </html>
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
        Step 2
        Create this field called Attachment type.
         
        var text Suffix = Right([Receipt Photo or Attachment],".");

        var text NonPhotoFileType = 
        Case($Suffix,
        "xls", "File",
        "xlsx", "File",
        "pdf", "File",
        "doc", "File",
        "docx", "File",
        "ppt", "File",
        "pptx", "File");


        If(
        Trim([Receipt Photo or Attachment])="","",
        $NonPhotoFileType<>"", $NonPhotoFileType, "Image")

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        Create the URL field type for the form. Type = URL . Set as iframe.  Set  800 by 800 size.

        If([Attachment Type 1]="File",

        URLRoot()&"db/"&AppID()&"?a=dbpage&pagename=iframe.html&rid="&[Record ID#]
        &"&tabledbid="&Dbid()
        &"&myurlroot="&URLRoot()
        &"&fileattachmentfid=9")

        // This field refers to iframe.html that is located in the pages section of this app. You will need to copy that code page into your app.
        // You will also have to copy the code from this button and update it for your button to reflect what your file attachment's field id (fid) is.  This this example the file attachment is 432.  Yours may be different.
        // Also be sure to "Allow open access     Allow access to this file attachment from a Quickbase link without signing in".  Edit the file attachment field properties and check the checkbox. Gviewer needs to be able to see the file in order to render it.

        ------------------------------
        Mark Shnier (YQC)
        [email protected]
        ------------------------------