I am facing an issue with the a!fileUploadField() component in Appian. The validation logic is supposed to restrict uploads to only PDF files, but it is not throwing an error when an XLSX file is uploaded. Below is my implementation:
a!fileUploadField()
a!fileUploadField( label: "File Upload", labelPosition: "ABOVE", target: cons!W500_KnowledgeCenter, maxSelections: 5, value: ri!File, saveInto: ri!File, validations: { if(fv!files.extension="PDF", "Error", "") } )
Discussion posts and replies are publicly visible
The documentation provides some examples.
https://docs.appian.com/suite/help/24.4/File_Upload_Component.html#all-files-must-be-pdfs
Yeah, But that code in doc is not working for multiple files,case:First upload a invalid Extension file ----- Shows validationSecond upload a valid extension file --------- Validation disappears.Third upload a invalid extension file ------------ Validation doesn't show up.
"fv!files" is a list. if you say "fv!files.extension = "pdf"", it will be asking Appian if the entire list of extensions is equal to the exact string "pdf", which it obviously won't be.
You will need to rewrite your code in such a way that you check all entries in the "fv!files" list for invalid extensions.
Hence the example Stefan linked:
e.g.
a!localVariables( local!file: {}, a!fileUploadField( value: local!file, saveInto: local!file, maxSelections: 3, validations: { if( contains(fv!files.extension, "pdf"), "no pdf allowed", "" ) } ) )
Mike Schmitt I think it won't work.I have tried with contains too.. It only works when we upload a single file.
Thanks Mike Schmitt .
The syntax for "contains()" is "contains(array, item to look for)". In your screenshot you have it reversed, thus there's no way for it to work until you fix it.
Thank you Mike Schmitt , It is working.
sureshkumarj8140 said:It is working
Cool, thanks for confirming. Please verify whatever answer(s) you found helpful when you get a chance.