Hi All,
First, some background: many of us still remember a time when using validations based on uploaded document properties (name, extension, size, etc) in a!fileUploadField() was not "officially" possible and therefore some of us were forced to resort to unsupported functionality to access these properties from just-uploaded documents, for various use cases. The most common use case, of course, was validating that uploaded files were of the correct type (extension), and thankfully a few versions ago, Appian added the fv!files property to the component, to access the important properties of uploaded documents.
Unfortunately, the fv!files feature was was only added to the Validations parameter, leaving a few other use cases not "officially" possible using supported functionality. To me, the most obvious of these use cases is:
I want to have a text field next to my a!fileUploadField component, which will pre-populate with the name of an uploaded document, and will be editable by the end user. The value of that field will then be used within the "fileNames" parameter of the file upload field, in such a way that any edits made by the user are saved as the uploaded document's name within Appian. (Note: to clarify, the specific part of this scenario that isn't possible is the ability to pre-populate the name of an uploaded file into another variable for use in a text field.)
Therefore, it would be incredibly useful if the saveInto Parameter could access the fv!files data in such a way as to allow us to duplicate any of the contained properties off to other rule inputs, local variables, etc.
Other use cases could include setting external variables due to specific extensions being uploaded, or specific sizes or size ranges, etc - there are probably dozens of valid edge cases that this feature would satisfy which now aren't possible unless using unsupported workarounds. Additionally, from an outside perspective at least, I would think this would have a high likelihood of being a low-effort add on the part of Appian's product engineers, since it would in certain ways duplicate the functionality currently enabled in the validations parameter of this component.
Everyone please let me know what you think.Thanks!
Discussion posts and replies are publicly visible
yeah.. I too had a similar scenario where in I have to save the file name in db when I upload a file.Hope fv!files will be made accessible in saveinto in future updates.
That's an interesting additional use case. Out of curiosity, is this DB table for auditing purposes, capturing every file someone uploads via the upload field, even if they remove it before submitting the form? Otherwise it seems like it would potentially introduce some confusing complexity to do this every time a new file is put into the upload field, since then it might be difficult to clear that information after the document is removed.
ACtually it's for storing the document name ,document id and other audit fields..But using an work around I was able to upload the data to db but I couldn't show the document name and couldn't use download link in the grid .As the document information is not saved in appain server , when I tried document function to fetch document name .It says document doesnot exist. Is there any work around for this scenario? I
The standard way to handle this is to have the user submit the form to commit newly-uploaded documents, at which point you can gather the document info and write it to the DB, and then (usually) loop back to the same form and display the previously-uploaded documents. Prior to the form being submitted, for example, the document can't be used in a document download link because freshly uploaded documents are stored in a special non-accessible folder in the Appian filesystem (hence the failure of the document() function).
yeah understood. Hopefully appian provides an update to over comes this technical limitation.
I believe it was intentionally set up this way for security reasons, so I would not expect an update that undoes this. The feature request I originally wrote about in this post is for added functionality to overcome particular limitations of this, since similar functionality had been added a while ago to be able to perform property-based validation on newly uploaded files.
oh okay..Got it..accessing the file properties in saveinto will really help..
Sad to see there's still no movement on this, even though there are posts in Community at least once every few weeks asking how to do something which would be easy if this were implemented, but impossible (or requires unsupported workarounds) without...
Hi Mike, there is a possible solution that allows you to solve this without any need for plug in.Simply evaluate an additional fileupload field in the save into and index into values.I have provided an example below:(Here, PRO_UXL_Index is simply performing a repeated index. You can of course simply wrap 3 layers of index() around the fileUploadField instead).I hope this helps, until Appian provide a robust solution. Of course, the same solution can be used for extensions.
a!fileUploadField( label: "File Upload", labelPosition: "ABOVE", value: ri!documents, maxSelections: 2, saveInto: { ri!documents, a!save( target: ri!fileNames, value: touniformstring( rule!PRO_UXL_Index( data: a!fileUploadField( label: "File Upload", labelPosition: "ABOVE", value: ri!documents, maxSelections: 2, saveInto: ri!documents, validations: {} ), path: { "contents", "value", "fileName" }, default: {} ) ) ) }, validations: {} )
That is an already known and dirty hack that could break any time. Definitely NOT recommended.