Is there any way to pre-populate documents in file upload field?

Requirement: Suppose if there are 10 rows in an editable grid of which one column is file upload file. If I upload a document in any of the rows for the first time, the file upload fields of other rows needs to be populated with the same document uploaded. After that whenever a document is updated in any of the rows, the new document should be saved. Kindly suggest a way. TIA

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Yes, it is possible.
    When you are uploading a document for the first time in a file upload field, update a rule input say ri!doc with the document id of the uploaded file. You can do that in the saveInto parameter. Similarly, you will have rule inputs for all other document upload fields say ri!doc1, ri!doc2,etc.
    Now, for all other file upload fields, in the value parameter, check if rule input corresponding to that file upload field is null say isnull(ri!doc1), isnull(ri!doc2), etc.. If it is null, make the value as ri!doc else keep it as ri!doc1....
  • Thanks for the solution.
    I tried this way. But this brings a new issue: "Once I upload a document for the first time, it gets auto populated to all other rows. But when I try to update any row with a new document, only the updated document gets saved." I found this error is due to the same document ID existence for all the fields being auto populated.
  • 0
    Certified Lead Developer
    in reply to ARUN RAMANATH

    You have to apply similar conditions in the saveInto parameter of each fileUploadField() except the first one.

    isnull(ri!doc1), isnull(ri!doc2), etc.. If it is null, make the saveInto parameter as ri!doc else keep it as ri!doc1....

  • But what if the first file (ri!doc) is just uploaded to the form which is not yet submitted. which means ri!doc will carry a temporary document ID. In such case, when I delete any of the auto-populated rows, the temporary document id pointing to the document gets deleted. Hence the first document is not getting saved whenever it is updated in any other rows.
Reply Children
No Data