Is it possible to get document id of uploaded file(a!fileUploadField()) within same interface without submitting a form?

I have uploaded a file using a!fileUploadField() and i want document id of uploaded file in same interface without submitting a form.

  Discussion posts and replies are publicly visible

Parents
  • I've just finished implementing a similar use case, where a user uploads an excel spreadsheet and Appian displays a grid of the rows inside the spreadsheet.

    I used 2 card layouts... one for Step 1: Import, and the second for Step 2: Display Grid. 

    Inside Step 1 card layout was the file upload field. Inside Step 2 card layout was the grid.

    The visibility of step 1 or step 2 was based on whether ri!spreadsheet was null or not. 

    local!showStep1: if (isnull(ri!spreadsheet), true, false),
    local!showStep2: if (isnull(ri!spreadsheet), false, true),

    Another local variable stored the uploaded file id (because the actual file data cannot be accessed until after the form has been submitted).

    a!fileUploadField(
    label: "",
    labelPosition: "ABOVE",
    target: cons!RP_Documents,
    fileNames: "excel_" & now(),
    value: local!spreadsheet,
    saveInto: local!spreadsheet,
    validations: {}
    )

    Notice I'm saving the uploaded doc into the local variable (above) and then saving the submitted file into the rule input on form submit (below). This lets me work with the data after the form has been submitted. It also lets me toggle the view of step 1 and step 2, plus test the form at either step just by passing in a document or leaving the rule input null. 

    a!buttonWidget(
    label: "Submit",
    icon: "table",
    saveInto: {
      a!save(ri!spreadsheet, local!spreadsheet),
      a!save(local!showGrid, true),
      a!save(local!showStep2, true)
    },
    submit: true,
    style: "PRIMARY"
    )

    Lastly, the actual import of the excel file to view in a grid, which is just a matter of iterating through arrays for the imported rows and columns, but that's not part of your particular scope so I'll leave that out of this solution.

Reply
  • I've just finished implementing a similar use case, where a user uploads an excel spreadsheet and Appian displays a grid of the rows inside the spreadsheet.

    I used 2 card layouts... one for Step 1: Import, and the second for Step 2: Display Grid. 

    Inside Step 1 card layout was the file upload field. Inside Step 2 card layout was the grid.

    The visibility of step 1 or step 2 was based on whether ri!spreadsheet was null or not. 

    local!showStep1: if (isnull(ri!spreadsheet), true, false),
    local!showStep2: if (isnull(ri!spreadsheet), false, true),

    Another local variable stored the uploaded file id (because the actual file data cannot be accessed until after the form has been submitted).

    a!fileUploadField(
    label: "",
    labelPosition: "ABOVE",
    target: cons!RP_Documents,
    fileNames: "excel_" & now(),
    value: local!spreadsheet,
    saveInto: local!spreadsheet,
    validations: {}
    )

    Notice I'm saving the uploaded doc into the local variable (above) and then saving the submitted file into the rule input on form submit (below). This lets me work with the data after the form has been submitted. It also lets me toggle the view of step 1 and step 2, plus test the form at either step just by passing in a document or leaving the rule input null. 

    a!buttonWidget(
    label: "Submit",
    icon: "table",
    saveInto: {
      a!save(ri!spreadsheet, local!spreadsheet),
      a!save(local!showGrid, true),
      a!save(local!showStep2, true)
    },
    submit: true,
    style: "PRIMARY"
    )

    Lastly, the actual import of the excel file to view in a grid, which is just a matter of iterating through arrays for the imported rows and columns, but that's not part of your particular scope so I'll leave that out of this solution.

Children
  • Step 1: showing the initial form. Take note of the rule input and local variables. Both are null at this point because we are waiting for a file to be uploaded.

    Step 2: File has been uploaded and the document stored in the local variable. The form has not been submitted yet.

    Step 3: Form gets submitted, and then we save the document into the rule input (while hiding Step 1's card layout, calling a rule expression to handle the parsing of the excel data, and then showing Step 2's card layout).

  • I have exactly the same use case as you described above, where I need to upload an excel document and display its data in a grid.  

    How are you extracting the data from the uploaded document to display in the grid?  I am aware of the Excel Tools plugin that provides the funcion "readexcelsheet", but I am wondering if there is a way to do this that does not require a plugin, or a better way to do this.

  • 0
    Certified Lead Developer
    in reply to walkers0001

    To confirm, you'll definitely need either this plug-in (Excel Tools), or a different one (if there is any other that has this functionality, which there might not be), as this functionality is not included in OOB Appian.  Why wouldn't you want to use a plug-in, though?

  • Yes, I used the Excel Tools plugin.

    Here's the rule expression I used:

    a!localVariables(

    local!excel: readexcelsheet(
    excelDocument: ri!spreadsheet,
    sheetNumber: 0,
    startRow: 2
    ),
    a!forEach(
    items: local!excel.result,
    expression: {
    app_id: fv!item.values[1],
    app_name: fv!item.values[2],
    app_owner_email: fv!item.values[3],
    app_department: fv!item.values[4],
    app_division: fv!item.values[5]
    }
    )
    )
  • 0
    Certified Associate Developer
    in reply to Rick Palmer

    Hello Rick,

    I have similar requirement except I want the user to have a look at the data in excel file before writing it to DB,
    So basically I want user to upload the excel file, Once that is done a read only grid will be shown having data in the excel file in that same interface below, then the user can decide to submit it or not.

    I wanted to know is it possible to do that in single interface.

    Thank You. 

  • 0
    Certified Lead Developer
    in reply to PK

    You can do it in a single interface, but you'll need to make the user click a "submit" button between uploading the Excel file and having Appian read its contents.  My normal suggestion here would be to add a button to the form saying something like "Load excel contents" that becomes enabled after the file is uploaded, which will then submit the task and cause the process model to loop straight back to the same task again.  As far as the user is concerned, they'll still be on the same task as when they started, plus or minus one button click to "load" the Excel contents.