Enable to return multiple values on a editableGrid

Certified Associate Developer

Basically im developing a start form where i get a list of records that contain a a docID and a dropdown. 

The interface has a editable grid where the user can add rows and per row the user can add a document (file uploadField) and a dropdown. 

My issue is that on both fields i selected the value and the save with ri!VALUE and when i add a document it makes it so that in all the rows that document is selected and the same for the dropdowns.

How can i make that per row created the save and the value creates a new array? In the interface i have already selected the ri! as multiple.  

ill leave the code here , and thanks in advance to all, 

a!localVariables(
  local!rowsTemp: a!gridRowLayout(
    contents: {
      a!fileUploadField(
        label: "Input File",
        labelPosition: "ABOVE",
        validations: {},
        target: cons!FOLDER,
        saveInto: ri!input[record.docID],
        value:local!doc,     
      ),
      a!dropdownField(
        choiceLabels: LABELS,
        choiceValues: codes,
        label: "",
        labelPosition: "ABOVE",
        placeholder: "--- Select a Value ---",
        saveInto: ri!input[record.docID],
        searchDisplay: "AUTO",
        validations: {}
      )
    }
  ),
  local!AddRow:  a!gridRowLayout(  contents: {
    a!fileUploadField(
      label: "Input File",
      labelPosition: "ABOVE",
      validations: {},
      target: cons!FOLDER,
      saveInto: ri!input[record.docID],
      value:local!doc,     
    ),
    a!dropdownField(
      choiceLabels: LABELS,
      choiceValues: codes,
      label: "",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      saveInto: ri!input[record.docID],
      searchDisplay: "AUTO",
      validations: {}
    )
  }),
 
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!gridLayout(
              label: "Input Doc",
              labelPosition: "ABOVE",
              headerCells: {
                a!gridLayoutHeaderCell(label: "Input Doc"),
                a!gridLayoutHeaderCell(label: "Doc Date")
              },
              columnConfigs: {},
              rows: { local!rowsTemp },
              selectionSaveInto: {},
              addRowLink: a!dynamicLink(
                label: "Add Source",
                value: a!map(
                  id: null(),
                  document: null(),
                  sourceType: null()
                ),
                saveInto: {
                  a!save(
                    local!rowsTemp,
                    append(local!rowsTemp, local!AddRow)
                  ),
                  a!save(local!rows, local!rows + 1)
                },
                showWhen: local!rowsUnder30,
 
              ),
              validations: {},
              shadeAlternateRows: true
            )
          }
        ),
        a!columnLayout(contents: {}, width: "NARROW_PLUS")
      }
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: "Run ",
          style: "OUTLINE"
        )
      },
      align: "END"
    )
)

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Please edit your post and put your code (making sure your indentation is preserved, though good job at getting indentation to show up in your original version) in a Code Box - it's 10x more readable that way.  I'll get to work on answering your question momentarily.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    a!localVariables(
    
      local!rowsTemp: a!gridRowLayout(
    
        contents: {
    
          a!fileUploadField(
    
            label: "Input File",
    
            labelPosition: "ABOVE",
    
            validations: {},
    
            target: cons!FOLDER,
    
            saveInto: ri!input[record.docID],
    
            value:local!doc,     
    
          ),
    
          a!dropdownField(
    
            choiceLabels: LABELS,
    
            choiceValues: codes,
    
            label: "",
    
            labelPosition: "ABOVE",
    
            placeholder: "--- Select a Value ---",
    
            saveInto: ri!input[record.docID],
    
            searchDisplay: "AUTO",
    
            validations: {}
    
          )
    
        }
    
      ),
    
      local!AddRow:  a!gridRowLayout(  contents: {
    
        a!fileUploadField(
    
          label: "Input File",
    
          labelPosition: "ABOVE",
    
          validations: {},
    
          target: cons!FOLDER,
    
          saveInto: ri!input[record.docID],
    
          value:local!doc,     
    
        ),
    
        a!dropdownField(
    
          choiceLabels: LABELS,
    
          choiceValues: codes,
    
          label: "",
    
          labelPosition: "ABOVE",
    
          placeholder: "--- Select a Value ---",
    
          saveInto: ri!input[record.docID],
    
          searchDisplay: "AUTO",
    
          validations: {}
    
        )
    
      }),
    
     
    
        a!columnsLayout(
    
          columns: {
    
            a!columnLayout(
    
              contents: {
    
                a!gridLayout(
    
                  label: "Input Doc",
    
                  labelPosition: "ABOVE",
    
                  headerCells: {
    
                    a!gridLayoutHeaderCell(label: "Input Doc"),
    
                    a!gridLayoutHeaderCell(label: "Doc Date")
    
                  },
    
                  columnConfigs: {},
    
                  rows: { local!rowsTemp },
    
                  selectionSaveInto: {},
    
                  addRowLink: a!dynamicLink(
    
                    label: "Add Source",
    
                    value: a!map(
    
                      id: null(),
    
                      document: null(),
    
                      sourceType: null()
    
                    ),
    
                    saveInto: {
    
                      a!save(
    
                        local!rowsTemp,
    
                        append(local!rowsTemp, local!AddRow)
    
                      ),
    
                      a!save(local!rows, local!rows + 1)
    
                    },
    
                    showWhen: local!rowsUnder30,
    
     
    
                  ),
    
                  validations: {},
    
                  shadeAlternateRows: true
    
                )
    
              }
    
            ),
    
            a!columnLayout(contents: {}, width: "NARROW_PLUS")
    
          }
    
        ),
    
        a!buttonArrayLayout(
    
          buttons: {
    
            a!buttonWidget(
    
              label: "Run ",
    
              style: "OUTLINE"
    
            )
    
          },
    
          align: "END"
    
        )
    
    )

    Here it is! 

    Thanks for the tip! Its my first time asking for something in this forum! 

  • 0
    Certified Lead Developer

    The main issue here is in your overall structure.  It's a clever idea to try to hold your rows in local!rowsTemp, but (at least as it's currently structured) it won't work - and may not be possible at all, though I haven't really tried to see if there is a way (if there were a way to get this structure to work though, it would involve some much more complicated code).

    The reason here is that the save target in the original "rowsTemp" ends up being identical to the save target in any subsequent addition.

    The way you're SUPPOSED to structure an editable grid is, in the "rows:" parameter, you should use a!forEach() to iterate over all items in your current data set (it can be a local variable or a rule input, but it should *always* be an array), because then each iteration (i.e. "fv!item[record.docId]") will point to a discrete data point.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    I understand what you are saying and thanks for your comment! The problem is that the ri! is a record that is empty so if i try to do as you are saying ill have the same issue, no? 

    when selecting the dinamicLink a new row will appear but the save and the value will be traced to the same place.. 

  • 0
    Certified Lead Developer
    in reply to baltazarC
    The problem is that the ri! is a record that is empty so if i try to do as you are saying ill have the same issue, no? 

    no - a!forEach() returns an array of zero items when the source target is empty.  all you need to do is set your "add row link" to append an empty row to the (empty array) RI value.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    thanks for both of your answers. thats exactly what im doing but still the docID is being saved on all the arrays of the ri! 

    and with that when i upload a file on the firts uploadFile i get it on all the upload Files 

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    or better, what would you insert in the save and value of the objects in those same rows? thanks

  • 0
    Certified Lead Developer
    in reply to baltazarC

    please post the current version of your code in a new comment (please use a code box).  Use a freshly copied version of your code from the interface editor so it doesn't accidentally end up with extra linebreaks between all lines.

  • 0
    Certified Lead Developer
    in reply to baltazarC

    Cool, thanks for giving it a shot - though I was hoping you might do this conversion on the original post (by editing it), just for space-saving purposes Wink  But it's academic now, if that version is out-of-date already.