Skip to main content
June 6, 2025
Question

Enable to return multiple values on a editableGrid

  • June 6, 2025
  • 13 replies
  • 0 views

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"
    )
)

    13 replies

    mikes0011
    Brainy
    June 6, 2025

    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.

    June 6, 2025

    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! 

    mikes0011
    Brainy
    June 6, 2025

    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 [emoticon:4191f5ee34e248a29fa0dbe8d975f74a]  But it's academic now, if that version is out-of-date already.

    mikes0011
    Brainy
    June 6, 2025

    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.

    June 6, 2025

    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.. 

    stefanhelzle0001
    June 6, 2025