submitUploadedFiles Function usuage

Certified Senior Developer

Hello there,

I have a Upload field where user uploads 50 rows of 2 columns data from/csv onto form.

I have to read all those and display the data in editable grid before submission.

To achieve this i have used submitUploadedFiles function with empty process model to start on its button click.

Even though data displayed on Interface object correctly, throwing error on front end.

Please help me if i did something wrong.

Added code snippet for upload and button

   a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: a!fileUploadField(
                instructions: "NOTE: CSV file size cannot exceed 50 rows and should only include tickers and weights",
                target: cons!SRT_FOLDER_UPLOAD_CSV,
                maxSelections: 1,
                value: ri!document1,
                saveInto: ri!document1
              )
            ),
            a!columnLayout(
              contents: a!buttonArrayLayout(
                buttons: a!buttonWidget(
                  label: "Read File",
                  saveInto: {
                    /*a!submitUploadedFiles(documents: ri!document1),*/
                   
                    /*a!save(local!validTickers,*/
                    /*reject(fn!isnull(_),index(a!flatten(index(rule!SRT_INT_bmuMorningstarUniverse(*/
                    /*tickers:index(local!fileTickers,"ticker",{})*/
                    /*),*/
                    /*"result","body","Universe","Security",{})),"Ticker",{}))),*/
                    
                    a!startProcess(
                      processModel: cons!SRT_PM_UPLOAD_FILE,
                      processParameters: {},
                      onSuccess: a!submitUploadedFiles(
                        onSuccess: {
                          a!save(local!submissionSuccessful, true),
                          a!save(
                            local!parsedFileData,
                            index(
                              readexcelsheetpaging(
                                ri!document1,
                                0,
                                a!pagingInfo(1, cons!SRT_INT_FILE_IMPORT_ROW_MAX),
                                2,
                                null,
                                true
                              ),
                              "data",
                              "values",
                              {}
                            )
                          ),
                          a!save(
                            local!fileTickers,
                            if(
                              rule!APN_isBlank(local!parsedFileData),
                              {},
                              a!forEach(
                                items: local!parsedFileData,
                                expression: a!map(
                                  ticker: if(fv!isFirst, null, fv!item[1]),
                                  allocation: if(fv!isFirst, null, fv!item[2])
                                ),

                              )
                            )
                          ),
                          a!save(
                            ri!portfolioData1,
                            append(
                              ri!portfolioData1,
                              a!forEach(
                                items: remove(
                                  local!fileTickers,
                                  wherecontains(
                                    null,
                                    index(local!fileTickers, "ticker", {})
                                  )
                                ),
                                expression: {
                                  'recordType!{5bf7f7cb-2b7c-430f-93b1-102a13b4f3af}SRT Portfolio'(
                                    'recordType!{5bf7f7cb-2b7c-430f-93b1-102a13b4f3af}SRT Portfolio.fields.{cb090f37-4d4b-43f3-9393-8ceb1cba74a5}tickerOrCusip': fv!item.ticker,
                                    'recordType!{5bf7f7cb-2b7c-430f-93b1-102a13b4f3af}SRT Portfolio.fields.{42f5fce0-6c85-488c-a1e6-ce2d5d14db86}productName': null,
                                    'recordType!{5bf7f7cb-2b7c-430f-93b1-102a13b4f3af}SRT Portfolio.fields.{154478bd-35f2-4ef1-b0f2-81449e3fb855}portfolioVersionRefId': 10,
                                    'recordType!{5bf7f7cb-2b7c-430f-93b1-102a13b4f3af}SRT Portfolio.fields.{277086ff-1613-4c0b-84e9-9932ba4f19bc}investmentType': null,
                                    'recordType!{5bf7f7cb-2b7c-430f-93b1-102a13b4f3af}SRT Portfolio.fields.{df7e6b6d-508d-4a78-8d12-41372a07944f}isActive': true,
                                    'recordType!{5bf7f7cb-2b7c-430f-93b1-102a13b4f3af}SRT Portfolio.fields.{1fc0f544-5ee9-4cdf-990a-e365e1a9d247}allocation': fv!item.allocation
                                  )
                                }
                              )
                            )
                          ),
                          },
                        onError: a!save(local!submissionSuccessful, false)
                      ),
                      onError: a!save(local!submissionSuccessful, false)
                    )
                  },
                  
                ),
                align: "START",
                marginAbove: "MORE"
              )
            )
          }
        ),

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    Thanks for responding.

    I tried using this function in the beginning of saveinto as well, however the problem is still same when we call it from Site front-end.

    Surprisingly it is working on a dummy site with dummy interface but failing on our actual Site.

    Works here on dummy as below: 

    = a!localVariables(
      local!document,
      local!submissionSuccessful,
      local!parsedFileData,
      local!items,
      local!button,
      local!fileTickers,
      
      {
        a!fileUploadField(
          target: cons!SRT_FOLDER_UPLOAD_CSV,
          maxSelections: 1,
          value: local!document,
          saveInto: { local!document  }
        ),
        a!buttonArrayLayout(
          buttons: a!buttonWidget(
            label: "Save",
            submit: false(),
            value: true(),
            saveInto: {
              local!button,
              a!submitUploadedFiles(
                onSuccess: {
                  a!save(local!submissionSuccessful, true),
                  if(
                    local!submissionSuccessful,
                    a!startProcess(
                      processModel: cons!SRT_PM_UPLOAD_FILE,
                      processParameters: {},
                      onSuccess: {
                        a!save(
                          local!parsedFileData,
                          index(
                            readexcelsheetpaging(
                              local!document,
                              0,
                              a!pagingInfo(1, cons!SRT_INT_FILE_IMPORT_ROW_MAX),
                              2,
                              null,
                              true
                            ),
                            "data",
                            "values",
                            {}
                          )
                        ),
                        a!save(
                          local!fileTickers,
                          if(
                            rule!APN_isBlank(local!parsedFileData),
                            {},
                            a!forEach(
                              items: local!parsedFileData,
                              expression: a!map(
                                ticker: if(fv!isFirst, null, fv!item[1]),
                                allocation: if(fv!isFirst, null, fv!item[2])
                              ),
                              
                            )
                          )
                        )
                      }
                    ),
                    {}
                  )
                }
              )
            }
          )
        ),
        a!gridLayout(
          headerCells: {
            a!gridLayoutHeaderCell(label: "Ticker"),
            a!gridLayoutHeaderCell(label: "Allocation"),
            
          },
          rows: a!forEach(
            local!fileTickers,
            a!gridRowLayout(
              contents: {
                a!textField(value: fv!item.ticker),
                a!floatingPointField(value: fv!item.allocation)
              }
            )
          )
        )
      }
    )
     

    but same code called inside the main interface is failing with same error

    This totally is weird.

  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    I am able to find the issue, just realized our main interface is running on start form where this function clearly not supportive.