Skip to main content
samadritam1018
February 16, 2023
Question

Multiple File Upload

  • February 16, 2023
  • 4 replies
  • 0 views

How can we make the File upload component as dynamic ? I have a rule input which has the type has a record type , so i cant select the multiple array option it it. The document id should be stored in the DB and the files should be saved in a Target folder.

4 replies

stefanhelzle0001
Brainy
February 16, 2023

You need to implement a separate record to hold the documents and define a one-many relationship from the original record to the new document record.

samadritam1018
February 16, 2023

I have been told -

You need to insert one row for each document you want to upload 

e.g  if you are uploading the 3 doc in single file upload then you will insert 3 differnt row in database 

1 row per each document .

How can I achieve this?

stefanhelzle0001
Brainy
February 16, 2023

I assume you are talking about some interface code.

The following code snippet works for me. You will have to adapt it to your scenario.

{
  a!fileUploadField(
    label: "File Upload",
    labelPosition: "ABOVE",
    value: index(ri!documents, 'recordType!{08eba301-a3a4-48a7-b036-9f1f6ad15733}TST Document.fields.{e4de7e9c-c508-46bf-8469-7ef29ce17201}document', null),
    saveInto: a!save(
      target: ri!documents,
      value: a!forEach(
        items: save!value,
        expression: 'recordType!{08eba301-a3a4-48a7-b036-9f1f6ad15733}TST Document'(
          'recordType!{08eba301-a3a4-48a7-b036-9f1f6ad15733}TST Document.fields.{e4de7e9c-c508-46bf-8469-7ef29ce17201}document': fv!item
        )
      )
    ),
    validations: {}
  )
}

jasonb1005
February 17, 2023

One option would be to create a rule input of type document with multiple values and save the multiple documents into that rule input. After that save all the document IDs into an array and use the joinarray() function with the separator ";". This will save the list as one long string with semicolons separating the individual IDs. This allows you to save all the IDs into one varChar row in your database. When you want to call that data back into an interface, you can use the split function separate the IDs again into individual document IDs.