Indexing to Lis of text String

Hi All,

I am trying to use indexing for type " List of Text String " but the output i am getting not the expected output i am adding the screenshots here for reference.

Thanks In advance,

SSP

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Senior Developer
    in reply to sivasuryap0002

    a!localVariables(
      local!excelData: index(readexcelimportfile(
        excelDocument: todocument(57745), /*put excel document id instead of 57745*/
        sheetNumber:0,
        startRow:0
      ),"result",{}),
      a!gridField(
        data: remove(local!excelData,1),
        columns: {
          a!forEach(
            items: local!excelData[1].values,
            expression: a!gridColumn(
              label: fv!item,
              value: index(fv!row.values,fv!index,{})
            )
          )
        }
      )
    )

    Please refer this code and see if it works.

Children
  • a!localVariables(
      local!exceldata,
      a!sectionLayout(
        contents: {
          a!fileUploadField(
            label: "Upload a File :",
            target: cons!IT_FOLDER,
            fileNames: "File Reading-File Uploaded on " & text(now(), "ddmmyyhhmmss"),
            fileDescriptions: "File Reading Interface Testing on File Uploaded on " & text(now(), "ddmmyyhhmmss"),
            maxSelections: 1,
            value: ri!uploadedFile,
            saveInto: {
              ri!uploadedFile,
              a!save(
                local!exceldata,
                index(
                  readexcelsheet(
                    excelDocument:todocument(ri!uploadedFile),
                    sheetNumber:0,
                    startRow: 0
                  ),
                  "result",
                  {}
                )
              )
            },
            required: true(),
            validations: if(
              contains({ "csv", "xlsx" }, fv!files.extension),
              {},
              "Only CSV,XLSX formats files should be uploaded but uploaded file is of format ." & fv!files.extension
            )
          ),
          a!gridField(
          label: "Excel Data :",
          emptyGridMessage: "Please Upload a File with Values",
          data: remove(local!exceldata, 1),
          columns: a!forEach(
          items: local!excelData[1].values,
          expression: a!gridColumn(label: fv!item, value: index(fv!row,fv!index,{}))
          ),
          showWhen: not(a!isNullOrEmpty(ri!uploadedFile))
          )
          
        }
      )
    )

    I have tried that but in the save into, I don't know why? but the readexcelsheet function is not working.
    Should we not use readexcelsheet in saveinto ?

  • 0
    Certified Senior Developer
    in reply to sivasuryap0002

    It is returning blank because the file is not in Appian System. you are just uploading it and the uploaded file will be in Appian system once you click on submit button. Make Sure, the interface where you are uploading the file is either a start form of the process model or a user input task.

    Just to check the code, you can manually upload the excel into Appian and copy the id of that document and put it into excelDocument configuration of the ReadExcelSheet function.

  • 0
    Certified Senior Developer
    in reply to sivasuryap0002

    a!localVariables(
      local!uploadedFile,
      local!exceldata,
      a!sectionLayout(
        contents: {
          a!textField(
            value:local!uploadedFile,
            saveInto: {
              local!uploadedFile,
              a!save(
                local!exceldata,
                index(
                  readexcelsheet(
                    excelDocument:todocument(57745), /*57745 is the document id. Please replace it with yours*/
                    sheetNumber:0,
                    startRow: 0
                  ),
                  "result",
                  {}
                )
              )
            }
          ),
          a!gridField(
            label: "Excel Data :",
            emptyGridMessage: "Please Upload a File with Values",
            data: remove(local!exceldata, 1),
            columns: a!forEach(
              items: local!excelData[1].values,
                expression: a!gridColumn(label: fv!item, value: index(fv!row.values,fv!index,{}))
            ),
            showWhen: not(a!isNullOrEmpty(local!uploadedFile))
          )
    
        }
      )
    )

    Please refer the above code