Hi everyone,
I have the requirement to display the attachments stored in a folder, whose unique names are present in database. I would like to provide a link to user in such a way that the name is displayed in the interface and when user clicks over it, the attachment gets downloaded.
Thank You.
Discussion posts and replies are publicly visible
Here's an example interface that assumes you're starting with a folder / folder ID containing documents, and displays each one as a consecutive link in a single Rich Text Display Field - this can be rearranged in any number of different ways depending on your particular need.
a!localVariables( local!documents: getdocumentsfromfolder( rootFolder: ri!folder, recursiveSearch: false() ), a!boxLayout( label: "Documents", contents: { a!richTextDisplayField( value: { a!forEach( local!documents, { a!richTextItem( text: { a!richTextIcon(icon: "file-o"), " ", document(fv!item, "name"), ".", document(fv!item, "extension") }, link: a!documentDownloadLink( document: fv!item ) ), char(10) } ) } ) } ) )
result:
Thanks Mike,
I would like to get the name from database and only matching name document should be displayed at each row. Could you please help me on this.
1.) what do you mean by "name from database"? Are you storing document names in a DB?2.) "Only matching name document" -> This means, you want to search all documents for a document with a specific name and if it matches, you want to display it and make it available?
Yes Richard, that is correct.
That will be diffcult.1.) I would trongly recomment to store the document ID not the document name.2.) Parsing through all documents at your environment is lets say imposisble to archive properly. 3.) additionally you need all documents converted by the document(xxx,"name") and then compared and as result you take a document id to make it available for download.-> the easiest way: store the document id, take the document id und make it available for download. You save so much complexity as you dont need to compare names to get a fit. Its the platform unique key/id of the document you want to download.
Thanks Richard for the explanation,
If you can provide some code snippet it will be very much helpful for me.
you can use Mikes suggestion above. Its pretty clean and well structured. But you will need one adjustment: Search in your DB for the suitable data which includes your DocumentId not a folder content.
a!localVariables( local!documentIds: rule!APP_QR_queryEntityRuleWhichGetYourDocumentIds(), a!boxLayout( label: "Documents", contents: { a!richTextDisplayField( value: { a!forEach( local!documents, { a!richTextItem( text: { a!richTextIcon(icon: "file-o"), " ", document(fv!item, "name"), ".", document(fv!item, "extension") }, link: a!documentDownloadLink( document: fv!item ) ), char(10) } ) } ) } ) )
Second idea: you can store a folder Id and look for folder content. For this case Mikes solution is perfect, if you load the folderId in your process and fill the input of the user input task with the loaded pv!-value for ri!folder