I am facing a problem where I want to store the exact size of an uploading file in a variable so that I can access it later to validate even if the section containing the file upload field is hidden. I am on v19.1. PS. By size, I mean the exact size in bytes and not "<1KB" which is retrieved by using fv!files.size. I cannot use a!save() function in validation attribute and fv!files.size is not accessible outside validation.
Discussion posts and replies are publicly visible
Once you upload the file, later in the process you can use the document function to get the size of the file.
The file is currently stored in a RuleInput. My concern is that if the file is of 0 bytes, I will allow the user to navigate to another section of the form but cannot let him submit the form. In this use case, there can be more than just a single file upload field on different-different sections and only the 0-byte file needs to be stopped and not 1 or more bytes file. Please let me know if I am clear.
If I understand correctly, you should still be able to apply the document function in this scenario. Once a document reference is stored in a variable (even if it's not a document type - use todocument()), you can use document(<documentvariable>,"size") to return a numerical representation of the size of the file and compare that to 0.If you save the the result of that operation, you can use it in the evaluation of a showWhen, or in a validation.
I tried it but the thing is document function cannot be used on a document which isn't completely uploaded and stored on Appian but only a reference of it exists. It shows as error "Either the document is missing or has been deleted"
That's correct. When do you need the size? Just after uploading the file or after submitting the form? In case you need after the uploading the file, you can do a work around on this. After uploading the file, provide a soft submit button which will submit the form and revert back to the same form, make use of chaining so the form will get submitted and reopen the form, by doing this your document will get uploaded to the KC folder and you will be able to get the size.
The things that you need to make sure is the values that the user have entered already, that should retain after clicking the soft submit button.