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