A Way to Validate an Uploaded File Before Submitting

I have discovered something and would like to share it with the community, while at the same time would like to know if this is "safe" to be used, or whether the slightest code change in Appian might cause it to misbehave.

A way of validating the uploaded file before submitting it, like validation on extension, file size, file name...etc.

When searching in the forum, the answer is: "it is not possible to be done without actually submitting the form and doing the checks after submitting."

But I have found a way to get it to work, and below is the method:

In the validation of the upload fileUploadField, call the object a!fileUploadField, passing the variable "value:ri!MainImage", assuming you are saving into "ri!MainImage" and then calling any properties like "uploadedDocumentName" as needed. This has worked for me perfectly.

Below is a code snippet:
a!fileUploadField(
label: "Main Image",
labelPosition: "ADJACENT",
...

OriginalPostID-153370

OriginalPostID-153370

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    @Rachel - I agree, which is why I've strongly suggested that anyone who uses this workaround solution encapsulate it into an external expression rule for easy updating if the functionality changes or becomes nonfunctional in the future. And of course the only reason many of us have used this workaround is because it's so badly needed.

    Accordingly, I would request that when new official functionality is developed for this, at least a slight amount of consideration is given to making it flexible enough that it can be included in expression rules, such as a new system function that is allowed read certain properties of a freshly uploaded file (like a!fileUploadField() can). That way, anyone who's implemented what I've recommended here could easily change it over to use the new official rule, and not need to chase down and manually change all the places we have a!fileUploadField used on a form.
Reply
  • 0
    Certified Lead Developer
    @Rachel - I agree, which is why I've strongly suggested that anyone who uses this workaround solution encapsulate it into an external expression rule for easy updating if the functionality changes or becomes nonfunctional in the future. And of course the only reason many of us have used this workaround is because it's so badly needed.

    Accordingly, I would request that when new official functionality is developed for this, at least a slight amount of consideration is given to making it flexible enough that it can be included in expression rules, such as a new system function that is allowed read certain properties of a freshly uploaded file (like a!fileUploadField() can). That way, anyone who's implemented what I've recommended here could easily change it over to use the new official rule, and not need to chase down and manually change all the places we have a!fileUploadField used on a form.
Children
No Data