Skip to main content
deepam0004
July 22, 2024
Question

Validation Group not working for file component

  • July 22, 2024
  • 8 replies
  • 0 views

ValidationGroup is not working as expected, when applied against a file component. It is validating entire form and not restricted to fileUpload component only. 

Requirement: When user clicks on "Upload File" button it should only validate file specific validations.

PS: I did try setting Validate: false for button component. But it did not work. 

Thanks for help in advance

a!fileUploadField(
labelPosition: "COLLAPSED",
target: tofolder(ri!appianFolderId),
instructions: "Please click on ''Upload File'' button to upload the file in system",
validationGroup: "UPLOAD_VALIDATE",

validations: {
if(
and(
a!isNotNullOrEmpty(fv!files.extension),
contains(cons!VALID_FILE_EXTENSIONS, upper(fv!files.extension))
),
"",
"File extension is not supported"
),
if(
fv!files.size > cons!FILE_SIZE,
"Attachment file size is more than 10 MB",
"",

),
},
value: ri!uploadedDocument,
saveInto: {
ri!uploadedDocument
},
maxSelections: 1,

),
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Upload File",
style: "SOLID",
submit: true(),
validate: true(),
validationGroup: "UPLOAD_VALIDATE",
disabled: a!isNullOrEmpty(ri!uploadedDocument)

)
}
)

    8 replies

    stefanhelzle0001
    Brainy
    July 22, 2024

    Can you share a code snippet that reproduces this behaviour in isolation?

    konduruc733182
    July 22, 2024

    Please share your code snippet. Have you used the validations parameter in the file upload field or only in the form buttons?

    stefanhelzle0001
    Brainy
    July 22, 2024

    konduruc733182
    July 22, 2024

    Why do you want to wait till the user clicks on the 'Upload File' button? Why not just let it evaluate at the component once the file is uploaded? Have you tried removing validation group in both the components and check?

    stefanhelzle0001
    Brainy
    July 22, 2024

    To exclude other input components, they will also need a validation group, but a different one.

    venkatrea696188
    July 22, 2024

    Hey Hi Stefan, isn't the Validation group is used to check whether the field is required or not on button click?? (It's not gonna validate what's in Validation param), In above code she haven't set the field required.... I have this doubt for longtime what's the proper use of Validation Group. AFAIK it's just checks the field required on button click not bothering about other validations it have

    stefanhelzle0001
    Brainy
    July 22, 2024

    Validation groups are used to create groups of input components and only trigger validations for specific groups.

    docs.appian.com/.../recipe-use-validation-group-for-buttons-with-multiple-validation-rules.html

    July 22, 2024

    AFAIK, the validation group controls the requiredness of the field, not the validation message.