Hi Team,
When using file upload I am saving the data in the database like:
a!fileUploadField( label: "Attach files", labelPosition: "ABOVE", target:cons!MPPCONSFLDR_SAMDocuments, maxSelections: 1, value:fv!item.documentid, saveInto: {ri!item.documentid, a!save(ri!item.documentid,tointeger(ri!item.documentid))
}, validations: {}
From the above code, I am uploading the file and saving it into the database in integer form.
now I want to retrieve that data and get the perfect link to that file, how can I get that?
Can I make the link of the file from this integer? if yes then how?
if no? then what can I use to save the direct uploaded file link in the database?
Discussion posts and replies are publicly visible
You can use the document ID to generate a download link, see an example below. Storing the document ID as you are doing above (vs a link) is the way to go. Quick note, your saveInto expressions above are redundant here although they will not cause any issues.
Replace the constant value here in local!doc with your a!queryEntity() to retrieve the document ID:
a!localVariables( local!doc: cons!YOUR_DOC_ID, a!linkField( label: "Download Link", links: a!documentDownloadLink( document: local!doc, label: document(local!doc,"name") ) ) )
As Chris already mentioned - your double save won't actually do anything, because the uploaded document ID will be cast to whatever type "ri!item.documentid" is, whether it be integer or document, regardless of how you execute the save.