GM: Just learning Appian as a business analyst. I have a basic app built, one CDT integer field as a array for documents, with the subsequent Appian-generated table for the "many" if the user loads more than one document. How do I display the list of documents for a particular record from that array field? I'd also like to use a link field so another user can download one of the documents if needed.
I've seen the editable grid pattern from other developers but I was hoping for a simpler solution since I'm still learning, and don't have a coding background?? thx in advance
Current code for single document but doesn't work for multiple:
a!textField( label: "Revised/additional documents", labelPosition: "ADJACENT", value: if(rule!APN_isEmpty(ri!record['recordType!Saving.fields.{folderId}folderId']),"-",document(ri!record['recordType!{Saving.fields.{folderId}folderId'],"name")&"."&document(ri!record['recordType!{Saving.fields.{folderId}folderId'],"extension") ), readOnly: true)
Discussion posts and replies are publicly visible
I suggest to use a!foreach() on that multiple field to dynamically create a list of a!richtextdisplayfield(). In that field, you add a richtextitem to display the text. These can take a link parameter which allows you to download the document using a documentdownloadlink().
Give it a try.
There's also a nice pattern that you can adapt with a list of documents - it's a little more complex, but I like the additional information displayed here: docs.appian.com/.../document-list-pattern.html
Thanks I like the pattern- I'm not very experienced with adjusting local variables- do I replace all of them with ri!record...? I have looked at the "Adapt a Pattern" doc and I'm just clarifying the guidance there. ty
Ah yeah I just realized that pattern doesn't pull data from documents - it actually has hardcoded data. You could use the document() function to find all of the properties that are displayed in that card, but it's a little tricky actually getting the data to show in the right format.
If you want, you could try to plug in something like this expression to replace the current definition for local!documents and it should work:
local!documents: a!forEach( items: rv!record['recordType!Saving.fields.{folderId}folderId'], expression: a!map( name: document(fv!item, "name"), description: document(fv!item, "description"), uploadDate: datetext(document(fv!item, "dateCreated"), "MMMM d"), size: document(fv!item, "size")/1000 & "KB", type: a!localVariables( local!extension: document(fv!item, "extension"), a!match( value: local!extension, whenTrue: contains({"xls", "xslx"}, fv!value), then: "excel", whenTrue: contains({"doc","docx"}, fv!value), then: "word", equals: "pdf", then: "pdf", default: "image" ) ) ) )
This will loop acroos the list of documents and identifiy properties for each document.
Thanks- I promise I tried but it didn't work for me- I don't have enough experience w the local variables. I'm going to review with a developer to see if we can get it working. ty!