Each File-type attribute can hold a collection of files. If you want to know how many uploaded files are associated to a single attribute, the best way to do so is by using the size property.
In the image below, an expression is created in order to count the number of uploaded files associated to the Documents attribute in the BusinessOpportunity Entity. The size property of the object is used in order to return the expected result through a ThrowValidationError. The expression is executed when Save is clicked in the form of a task for testing purposes.
//Get array of files
CHelper.ThrowValidationError("Number of Files Uploaded = " + OFiles.size());
The expression first obtains the array of files stored in the RelatedDocuments file-type attribute. A message is then displayed to the end user by using a Validation. In this the number of files updated is obtained by using the .size property in order to be displayed.
When there are no files uploaded, the number of Files Uploaded returned in the message must be 0.
On the other hand, when there are two or n files uploaded, it has to be reflected in the message returned. This behavior is shown in the image below.