I am implementing a gridRowLayout. Inside the gridRowLayout I am implementing a fileUpload field.
So that I can add a new row dynamically and for each row I can upload 1 document.
But the demand here is ... I cant upload same files again and again (i.e. I cant upload same files in different rows) . But I am not quite sure how to do the validation for it. Can anyone help me with this ?
This validation I have added for fileName. But as you see I could upload same files. I need validation to say that File Already Uploaded. Is there a way to do this validation ?
Discussion posts and replies are publicly visible
Hi,
Can you share your code snippet?
a!localVariables( local!uploadedDocuments: index(ri!data, "uploadedFiles", null), a!gridLayout( label: "UPLOAD FILES", headerCells: { .. }, columnConfigs: { .. }, rows: { a!forEach( items: local!uploadedDocuments, expression: { a!gridRowLayout( contents: { a!fileUploadField( target: cons!TargetFolder, label: "Attach Documents", labelPosition: "ABOVE", maxSelections: 1, value: .., saveInto: {..}, ), a!richTextDisplayField( value: a!richTextIcon( icon: "times", link: a!dynamicLink( saveInto: {..} ), linkStyle: "STANDALONE", color: "NEGATIVE" ), showWhen: not(ri!readOnly) ) } ) } ) }, addRowLink: a!dynamicLink( label: "Attach New Document ", saveInto: {..}, showWhen: not(ri!readOnly) ) ),)
There is no validation defined here , but sharing a sample code which you can try.
{ a!fileUploadField( label: "File Upload", labelPosition: "ABOVE", target: cons!DOCUMENTFOLDERCONSTANT, value: ri!documents, saveInto: ri!documents, validations: reject( fn!isnull, a!forEach( items: union({ fv!files.name }, { fv!files.name }), expression: if( count(wherecontains(fv!item, { fv!files.name })) > 1, fv!item & " is uploaded by you earlier please remove it", null ) ) ), buttonDisplay: "LABEL" ) }/* documents RI is of type document and array type*/
Is there a reason to add these curly brackets in line 11 and 13? While this should not be an issue here, but there are edge cases where adding curly brackets breaks code. I would not make that a habit and only add them when necessary.
Hi , yes you are right we do not need to use {} in said places. Out of curiosity, can you please tell us the scenario that you encountered where this would break the code , if you recall any.
Thanks
Thanks for this