Upload and analyze a file in a User Input Task

Certified Associate Developer

Hi everyone,

Im using an User Input Task with a!fileUploadField. What I need is to verify that the Excel uploaded does not contain mor than 500 rows so the user cannot submit the form. But as the file is temporary I cannot access to its information, and I alreay saw that it is not possible using a!submitUploadedFiles function. Any ideas for solving this?

Thank you!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Whether you are using folder stored documents or record managed ones you can read the data in the saveInto of the fileUpload component and using that validate the data. Here is a code you can refer which uses readexcelsheetpaging() which comes as part of Excel Tools plugin. 

    a!localVariables(
      local!dataLength,
      {
      a!fileUploadField(
        label: "Docs",
        target: cons!HSS_DOCUMENTS_TARGET,
        maxSelections: 1,
        saveInto: {ri!doc,
        a!save(
          local!dataLength,
          readexcelsheetpaging(
           ri!doc,
            0,
            a!pagingInfo(1, 50)
          ).totalCount
        )},
        instructions: ri!doc,
        validations: if(local!dataLength>20,"Maximum 20 rows are allowed",""),
        value: ri!doc
      )})

    P.S My code is written & tested in Appian v25.2 & v25.3. Check if it works for you depending on the version you are working on! Let me know how it goes.  

Reply
  • 0
    Certified Lead Developer

    Whether you are using folder stored documents or record managed ones you can read the data in the saveInto of the fileUpload component and using that validate the data. Here is a code you can refer which uses readexcelsheetpaging() which comes as part of Excel Tools plugin. 

    a!localVariables(
      local!dataLength,
      {
      a!fileUploadField(
        label: "Docs",
        target: cons!HSS_DOCUMENTS_TARGET,
        maxSelections: 1,
        saveInto: {ri!doc,
        a!save(
          local!dataLength,
          readexcelsheetpaging(
           ri!doc,
            0,
            a!pagingInfo(1, 50)
          ).totalCount
        )},
        instructions: ri!doc,
        validations: if(local!dataLength>20,"Maximum 20 rows are allowed",""),
        value: ri!doc
      )})

    P.S My code is written & tested in Appian v25.2 & v25.3. Check if it works for you depending on the version you are working on! Let me know how it goes.  

Children
No Data