Validation for Array of Documents

Certified Senior Developer

Hi All,

I have multiple sections where the user can upload document and for each section we have "add document" button like below,

I have to validate for document size if it is more than 10MB,and this validation is for add document button.I am not getting how to validate the document based on index using fv!files.

Because of this,if user adds more than 10MB in 1st sec and adds less than 10 MB in 2nd sec,for both section it validates for "Add Document" button.

Please help me how to resolve this.

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    I don't use ValidationGroups often.  But this seems like a time it might work.

    Your problem is you're adding everything to the same ValidationGroup tag.  As far as I know, the ValidationGroup tag doesn't care about on-form positional context or anything like that.

    Remember that ValidationGroup is just a string - if your file upload fields and "add document" buttons are part of an array, then you could just append the current index to the validation group text, meaning each subsection with its own upload / button pair would have its own validation group.

    I'd strongly caution you though - you're submitting this form on the first press of a valid "add document" button.  As soon as that's pressed, *all* file upload field contents will be persisted to their target Appian folder, regardless of whether they pass the validation check in their own section.  If you're submitting the form and re-loading it again to allow the user to work on the next document, then all documents added to any file upload field up to that point will now be sitting in their target folders, even if the user then proceeds to remove one or more document(s) and upload replacements.  Thus I'd concentrate most on a solution where the user uploads all needed files and all are validated *before submission*.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Hi Mike, thanks for the reply. I am submitting this form every time on click of add document because I want to show the user added doc as a link to download the document ,please let me know if there is anyway to achieve this without submitting the form?

Reply Children