Upload several files and save to database

Hello, 
I need help!!
I have this field to upload documents to a database

a!fileUploadField(
label: "Document",
labelPosition: "ADJACENT",
/*maxSelections: 1,*/
value: ri!newDo.docum,
saveInto:
{
ri!newSoli.documentation,
ri!newDo.docum,
a!save(ri!newDo.day,now())
},
target: cons!C_FLD_document,
validations: {}
)

What I want to achieve is that when uploading several documents I can do it and it does not appear
"Expression evaluation error in rule 'cpro_i_nuevasolicitud' at
function a!fileUploadField [line 146]: Error in a!forEach()
expression during iteration 1: Expression evaluation error at
function fn!content_appian_internal
[line 12]: Null Arguments are Invalid"

THANKS



  Discussion posts and replies are publicly visible

Parents Reply Children
  • Thanks! 

    But I do not know what to put to replace
    local! loadedFiles
    fv! index

    it would be like this?
     a!fileUploadField(
    label: "Document",
    labelPosition: "ADJACENT",
    /*maxSelections: 1,*/
    value: ri!newDo.docum,
    saveInto:
    {
    a!forEach(
    items: ri!newDo.documentation,
    expression: {
    a!save(ri!newDo.documentation[fv!index].fileAttached, fv!item)
    }
    ),
    ri!newSoli.documentation,
    ri!newDo.docum,
    a!save(ri!newDo.day,now())
    },
    target: cons!C_FLD_document,
    validations: {}
    )
  • declare a local variable and use it in your fileUploadField control.

    code for  file upload field:

    a!fileUploadField(
       label: "Document",
       labelPosition: "ABOVE",
       target:cons!C_FLD_document,
       value: local!loadedFiles,
       saveInto: local!loadedFiles,
       validations: {}
    )

    put the below code in your button saveInto:

    saveInto: {
    a!forEach(
    items: local!loadedFiles,
    expression: {
                  a!save(ri!loadedFiles[fv!index].fileAttached, fv!item)
    }}

    -----------------------------------------------------------------

    ri!loadedFiles: is your CDT where you are loading the files.

    fileAttached: a column in your CDT

  • How to store a structure multiple file uploaded into DB column and retrieve from DB ? for downloading