File Upload Validate Extension On Button Disabled

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

Parents
  • 0
    Certified Lead Developer

    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.

    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.

Reply
  • 0
    Certified Lead Developer

    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.

    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.

Children
No Data