Forum Discussion

ChadCox's avatar
ChadCox
Qrew Trainee
7 years ago

API_GenResultsTable javascript field that contains url link not present

I am using API_GenResultsTable with jsa=1 to return a JS array of data. It has been working great, until now, when I notice I cannot get the URL for a link that shows up. My QB report will have a column that shows links to PDF files. 


When I use API_GenResultsTable jht=1 (to generate HTML) I can get the full URL, as shown below. 
document.write ("<td class=m  align=left><a href=\x22\/up\/abcd318dxb\/g\/re3a\/eqb\/va\/My%20file.pdf\x22  target=_blank>My file.pdf<\/a><\/td>");


When I use API_GenResultsTable jsa=1 (to return JavaScript data), I get the result below.
qdb_data[4][9] = "My file.pdf";


I am unable to recreate the URL for each of those files in the JavaScript array. If I have a report with 10 records being returned, all 10 records have different URL paths, so nothing I can logically determine to create the URL.


Example:
document.write ("<td class=m  align=left><a href=\x22\/up\/abcd318dxb\/g\/ra2s\/eqb\/va\/My%20file.pdf\x22  target=_blank>My file.pdf<\/a><\/td>");
document.write ("<td class=m  align=left><a href=\x22\/up\/abcd318dxb\/g\/re5a\/eqb\/va\/My%20file1.pdf\x22  target=_blank>My file1.pdf<\/a><\/td>");
document.write ("<td class=m  align=left><a href=\x22\/up\/abcd318dxb\/g\/rd3e\/eqb\/va\/My%20file2.pdf\x22  target=_blank>My file2.pdf<\/a><\/td>");


The "ra2s" and "re5a" and "rd3e" is the part of the URL that varies. I am not sure where to get that data specific for each file.


Any help? Thanks!

3 Replies

  • Read this section of the HTTP API docs which describes two different ways of building URLs to file attachments:

    File Management
    https://help.quickbase.com/api-guide/filemanagement.html

    You will probably have to build a formula for the URL from the [Record ID#], and the known fid and version like this:
    "https://quickbase.com/up/"; &
    Dbid() &
    "/a/r" &
    [Record ID#] &
    "/e8/v0"
    In the above fid=8 and version=0.

    Include this formula URL field in your clist when using API_GenResultsTable.
  • ChadCox's avatar
    ChadCox
    Qrew Trainee
    Thank you for your help. If I do something like this and look at the data returned, can I get the Record ID and the known FID?

    target_domain.quickbase.com/db/abcdae?a=API_GenResultsTable&qid=16&nv=1&v0=356&clist=a

    I see data returned and I can see my file in that data. When I hover over the file in the results displayed (because the file is clickable), I can see the URL that will download it, but I am not seeing the IDs in that URL present in my results of the page request above.

    I see a column called "Record ID#." It shows 4615 in the HTML table (from above). I also see a "Related Vendor" number as 1777. When I hover the clickable links for this vendor in this record of the HTML, I can see rid=1777, making me think 1777 is more useful to me than 4615.

    At this point, I know DBID. I am not sure I know RID. I do not know FID nor VID. Is FID the name of the file ("My file.pdf"), or is FID something else?

    I am trying to make requests to a url like this, but with no results. I am using my real url unlike what I am showing below.

    target_domain.quickbase.com/up/abcdae/a/r1777/e0/v0
    target_domain.quickbase.com/up/abcdae/a/r1777/e1/v0
    target_domain.quickbase.com/up/abcdae/a/r1777/e2/v0
    target_domain.quickbase.com/up/abcdae/a/r1777/e3/v0
    ...
    target_domain.quickbase.com/up/abcdae/a/r4615/e0/v0
    target_domain.quickbase.com/up/abcdae/a/r4615/e1/v0
    target_domain.quickbase.com/up/abcdae/a/r4615/e2/v0

    Thanks for any clarification.


    • ChadCox's avatar
      ChadCox
      Qrew Trainee
      I figured it all out in QB. Thanks for your help.