Jump to content
  • 0

Use File upload as a link in a Case Statement



Thank you in advance for your help.

I have two upload locations. The first one is the Caspio upload to the Caspio file section. My users are uploading very large scanned files (PDFs), and I had to create a separate upload page outside of Caspio and outside storage. However, I have a tabular data page that shows the upload link. I need to create a CASE statement that will determine if the old document upload ( [@field:ISDocumentUpload])was used; if not, then the new URL ([@field:ISFileURL]). This is what I have so far, but I am having problems getting the URL of the Capsio upload location.

WHEN [@field:ISDocumentUpload] IS NOT NULL
THEN '<a href="@FileUploadField">Download File</a>'
ELSE '[@field:ISFileURL]'


So far the <a href="@FileUploadField">Download File</a> only shows a link that changes when you hover, but there is no destination URL inserted.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hello @Hiperf

Could you specify what your intention is by adding @FileUploadField? The syntax does not seem right because when referring to a field from the table, it should be [@field:FileUploadField]

What is the field name of the native file field? Is it ISDocumentUpload or FileUploadField?

 To create a link to the file from the file field, first, you need to enable filestore CDN: https://howto.caspio.com/files-and-images/filestor-cdn/

After that, you can get a URL to the file using the specified in the article structure.

Link to comment
Share on other sites

  • 0

I have two different upload locations; the old one is through Caspio using the File Field, and the new upload location is to our server. I need to keep the old one active for 14 months so the users can click a link on the record and download the file. I am trying to display only one column for the download link; see attached.

Screenshot 2024-02-05 171031.png

Link to comment
Share on other sites

  • 0


Hello @Hiperf

I can suggest the following:

1. You need at least 3 columns on your report: 
2. You leave FileUploadField and ISFileURL columns as it is (meaning that they have their respective download links)

3. You add this JavaScript to the header or footer of your DataPage:


if (document.DataPageReadyHandler == undefined) {
const ISDocumentUploadPosition = 1
const FileUploadFieldPosition = 2
const ISFileURLPosition = 3

const hideCells = () => {
document.querySelectorAll(`.cbResultSetTableHeader th:nth-child(${FileUploadFieldPosition}), 
                           .cbResultSetTableHeader th:nth-child(${ISFileURLPosition}), 
                           .cbResultSetDataRow td:nth-child(${FileUploadFieldPosition}), 
                           .cbResultSetDataRow td:nth-child(${ISFileURLPosition})`).forEach(el=>el.style.display = 'none')


const DataPageReadyHandler = (e) => {
 if (e.detail.appKey != '[@cbAppKey]') { return }
 let ISDocumentUploadCell = tr.querySelector(`td:nth-child(${ISDocumentUploadPosition})`)
 let FileUploadFieldCell = tr.querySelector(`td:nth-child(${FileUploadFieldPosition})`)
 let ISFileURLCell = tr.querySelector(`td:nth-child(${ISFileURLPosition})`)
 if (ISDocumentUploadCell.innerText.trim() != '') {ISDocumentUploadCell.innerHTML = FileUploadFieldCell.innerHTML}
 else {
 ISDocumentUploadCell.innerHTML = ISFileURLCell.innerHTML


document.addEventListener('DataPageReady', DataPageReadyHandler)
document.DataPageReadyHandler = 'Enabled'


You need to specify the order position of these respective columns in your report by changing the values of the following variables:

const ISDocumentUploadPosition = 1
const FileUploadFieldPosition = 2
const ISFileURLPosition = 3

The JavaScript will hide FileUploadField and ISFileURL columns, and based on your condition, it will show either FileUploadField or ISFileURL download links in ISDocumentUpload column

Here is an example with 2 records: https://c7eku786.caspio.com/dp/7f80b000d31047d6d3f54422a625
One link is taken from FileUploadField, and another from ISFileURL

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...