how do i display a picture from a child record?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

Parent table: "Sites"

Child Table: "Dispatches"

i'm required to have pictures each quarter, and required to dispatch to site every two months. I'd like to create a summary field on the "Sites" table that will pull a picture from the most current "Dispatch" if it is during a specific quarter of the year.

Photo of M

M

  • 60 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,894 Points 20k badge 2x thumb
If the most recent image in the Dispatch table related to the current Sales record you are viewing also has the largest [Record ID#] there is a native way to do this that relies on a way of addressing file attachments using this URL scheme:


If you know the database ID, the record ID, the Field ID of the file field you are attaching to, and the version ID, you can use issue a GET request using this URL format:

https://SUBDOMAIN.quickbase.com/up/DBID/a/rRID/eFID/vVID

where:

DBID is your TABLE dbid (not the application dbid)
RID is the rid of the record with the File attachment
FID is the fid of the File attachment field,
VID is the version ID of the file. Specifying 0 (zero) for the VID always gets you the most recent version

http://www.quickbase.com/api-guide/index.html#filemanagement.html

To implement this you create a summary field on the Maximum [Record ID#] in the Dispatches table and call this field say [MaxDispatchRid]. Then create a text formula field with some HTML allowed using a formula like this:
"<img src=" & "https://SUBDOMAIN.quickbase.com/up/DBID/a/r" & ToText([MaxDispatchRid]) & "/eFID/v0" & ">"
You will need to substitute your SUBDOMAIN, DBID and FID (but keep the leading "e") and otherwise parameterize and neaten up the formula to suit your needs.
Notes (1) If the most recent image does not also have the maximum  [Record ID#] you have to introduce additional summary and lookup fields to "float" the appropriate [Record ID#] up to the parent Sales table.
(2) I noticed that the API document does not mention the SUBDOMAIN so I used the handy comment link at the bottom of every API page to report it. It is very easy to do and helps improve the documentation. See screenshot.