Linking to Form File Uploads in an Asset List


(Miriam Clinton) #1

By default in 3.24.3 there is no keyword for me to print the URL or asset ID of a file uploaded to a custom form (which would be a really handy feature if it is not already in a later version, hint hint :slight_smile: ). I needed to create an asset listing to print form submissions along with attachments uploaded to the form.


I figured that unless there is a ridiculous amount of traffic going on, the asset ID of an uploaded file is always going to be one greater than the custom form. So a little bit of math and jQuery helps me print a link to an uploaded file.



First set up an asset list to list form submissions as per the Custom Form manual.



This section goes in the Form Submissions Type Format of my asset listing:

    
    




(Replace XXXXXX with the ID of your question and Y with the question number, as you would normally do when printing form submissions.)



Now add a div within the Form Submissions Type Format where we want to print the link to the attachment, using the form submission's asset ID as the div ID:


    

(Miriam Clinton) #2

Small bugfix for this which I thought I should post before people get embarassing results from my script!


It helps to test that there is actually a file uploaded with the form submission before trying to link to it! :wink: