Is there a way to capture delete instance in file upload field?

Requirement: 

I have a file upload field as a column in editable grid. And I'm auto-populating the first uploaded document to all other rows in the editable grid. Now when I need to update a document in any other rows with a new document, the first uploaded document value is shown in grid but is not getting saved to KC. This is because all the auto-populated documents have same documentID. As I delete and update any of the auto-populated document with a newer document before submitting the form, the first uploaded document gets deleted as all the auto-populated documents will point to the first uploaded documentID . 

In order to overcome this, I would like to add a validation : once all the file upload fields are auto-populated after uploading first document, before clicking delete button in any of the uploaded documents, I wish to enable a custom BUTTON to upload the files, so that after uploading, updating of documents is possible. So for this, kindly suggest is there any way to capture the deleting instance in a file-upload field

 

TIA

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Not sure if I am understanding everything correctly, but it sounds like:
    1. You have an editable grid with one of the columns being a file upload field
    2. For the first gridRowLayout, when user's upload a file through the file upload field, all the other gridRowLayout's file upload fields are pre-populated with this first file
    3. Users are then able to change these pre-populated file upload fields with new documents

    And your issue is at step 3, in which changing any of the other rows file upload fields with new documents leads to changing of the initial document.
    If that is the case, it almost sounds like you have a singular variable that is being used for each row of the grid. If you do, the solution is to have a list of documentIds (e.g. ri!documentIds) that you pass into each gridRowLayout. Each gridRowLayout should also keep track of which row in the grid it is responsible for (e.g. ri!index). Once you do that, each gridRowLayout's file upload field can save into ri!documentIds[ri!index] and you wont overwrite other row's documents. For the first row, to prepopulate all the documents, you can simply repeat the initial documentId as many times as there are rows in the grid and then save it to the ri!documentIds list.

    Hope this helps.
Reply
  • 0
    Certified Lead Developer
    Not sure if I am understanding everything correctly, but it sounds like:
    1. You have an editable grid with one of the columns being a file upload field
    2. For the first gridRowLayout, when user's upload a file through the file upload field, all the other gridRowLayout's file upload fields are pre-populated with this first file
    3. Users are then able to change these pre-populated file upload fields with new documents

    And your issue is at step 3, in which changing any of the other rows file upload fields with new documents leads to changing of the initial document.
    If that is the case, it almost sounds like you have a singular variable that is being used for each row of the grid. If you do, the solution is to have a list of documentIds (e.g. ri!documentIds) that you pass into each gridRowLayout. Each gridRowLayout should also keep track of which row in the grid it is responsible for (e.g. ri!index). Once you do that, each gridRowLayout's file upload field can save into ri!documentIds[ri!index] and you wont overwrite other row's documents. For the first row, to prepopulate all the documents, you can simply repeat the initial documentId as many times as there are rows in the grid and then save it to the ri!documentIds list.

    Hope this helps.
Children
No Data