I am trying to keep the submit button disabled if they have not selected a file and if the file is not a CSV extension.
The button disable works fine for check for no file but the file extension checking is not working and can not figure out why.
In the below code the first if is working fine but the second one it gets this error
Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function 'document' [line 45]: The passed parameter(s) are of the wrong type. Received the type Text. and can not figure out why. Is there a better way to check this? Thank you for any help on this, also the ri!csvFile_txt it saves into show this [Document: 383603] as the value for it. The upload also works fine with the csv file as well, just having the issue on the disabled validation part.
primaryButtons: { a!buttonWidget( label: "Submit", submit: true, style: "PRIMARY", disabled: if( rule!APN_isEmpty(ri!csvFile_txt), true(), if( find("CSV", a!fileUploadField(value: upper(document(ri!csvFile_txt, "extension")))) > 0, false(), true() ) ) ) }
Discussion posts and replies are publicly visible
The best way to add a validation to your form is to use the validation feature of each input component. Is there a specific reason for not using that?
I am using the validation feature on the upload file component, when you pick a file that is not a csv file it tells the user the file is invalid and to remove it and pick a csv file. But I need the submit button to stay disabled until they pick a csv file.
The code you're trying to execute here is invalid in a few different ways.
find("CSV", a!fileUploadField(value: upper(document(ri!csvFile_txt, "extension"))))
And even if you did correct that to do what I assume you're trying to do, it's still unsupported functionality.
williamm0010 said:The passed parameter(s) are of the wrong type. Received the type Text.
This is because you're trying to pass in a "value" for the File Upload Field, but the "value" you're passing is text. The value for the File Upload Field must be document, not text.
Why do you "need" to do that? Is that a requirement? If yes, why?
They are asking for the submit button to stay disabled until a valid csv file is dropped into the upload box. So when a valid csv file is dropped in the upload box the button can be pressed, if no file picked yet disabled, if they pick a .docx keep it disabled until .csv file is picked...
I think the point Stefan is trying to make is, what you describe is design and not requirement. As in, the fact that you can validate against a .csv file being uploaded, means the user will be unable to submit the form, regardless of whether the button is disabled - and thus the end result will be exactly the same.
That is to slick, even though I picked a .doc file the upload button still shows but when I click it nothing happens. That will work, thank you guys for your help.