Hi,
I need to upload a file. Before uploading in the entity, I need to check whether the same file name exits in the entity. I gave a condition like UploadFilename = GetFileUploads.List.Current.FileUpload.Filename. But this will check only the latest file that is uploaded in the Entity, if it has more than 2 files the condition would fail. How can I check my UploadFilename is not already stored in my Filename attribute ?.
Hello,
You're approaching this the wrong way. Every time the user tries to upload a file, you need to check the database again for that file name. So what you could do is create a new Server Action that takes as an input parameter the file name to check and then runs a new aggregate on your FileUpload entity with a condition similar to "FileUpload.Filename = InputFileName". The action can return a boolean indicating whether a file with the specified name was found.
Then, in your client action, you call this new server action passing in the file name and check the output. If a file with that name already exists, you stop the process and show a message to the user.
Hi Annie,
You simply use a list filter in place of the if condition.
Take aggregate in a source list like GetFileUploads.List and put the condition FileUpload.Filename = UploadFilename. Then take the if condition and check if the list is not empty then give a validation message or if the list is empty the file is uploaded.
Thanks, If you need OML on it please let me know.
Regards
Parveen
That’s a bad idea. There might be multiple users access the application and uploading files, so to really ensure that file names are unique, you have to check it immediately before saving the file to the database.
Hi, Thank You, @Aurelio Junior the above solution works. Before uploading in the FileUpload Entity, I initially append all my file name in the list. How can I give the condtion before this ListAppend whether that file already exits in FileMetaInfoList?
I'm not sure I understand. Are you still trying to check if the file that is being uploaded already exists in the database?
In any case, if you want to check whether a certain element already exists in a list, you can use the "ListAny" action from "System":