(FormName[File_upload == input.File_upload].count() > 0)
doesn't seem to work.
Neither did
(FormName[File_upload.contains(
input.File_upload)
== true].count() > 0)
Any suggestions? (And as usual any help will be greatly appreciated!)
SOLVED IT:
The problem with the above attempts was that ZC adds a unique string of digits prefix to the front of each File_upload field string to differentiate that file from files uploaded to other records which might have the same file name.
The solution was to create string field, I called it UploadFileNameHolder and use it to hold the part of the File_upload field string which is the name of the file uploaded (the string which is the suffix to the unique string of digits prefix which ZC adds to the front of the file name). Fortunately, ZC also adds an underscore ( _ ) after their unique string of digits...this was the key to the solution.
Here are the scripts that did the trick:
onAdd-onSuccess AND
onUpdate for the File_upload field
:
UploadFileNameHolder =
File_upload.getSuffix("_");
onValidate:
if (FormName[UploadFileNameHolder == input.UploadFileNameHolder].count() > 0)
{
alert "Can't upload duplicate file name";
cancel submit;
}
Also needed to create a function and execute it in order to go back and set the values of the UploadFileNameHolder field in all the old records to File_upload with the ZC prefix removed:
void UploadFileNameHolderUPDATE()
{
for each r in FormName [File_upload != ""]
{
r.UploadFileNameHolder = r.File_upload.getSuffix("_");
}
}