Skip to main content
New Participant
Mar 28, 2025 4:00 AM UTC
Question

#Unabable to update values in SIte level

Hello all, I am currently working on an interface that includes an editable grid. Although the backend processes the percentage field modifications correctly, the site displays incorrect values, particularly in some other rows.

3 replies

davidj137213
Brainy
Mar 29, 2025 7:36 AM UTC

Could you explain the problem  a little bit please?

stefanhelzle0001
Brainy
Mar 29, 2025 8:03 AM UTC

What exactly does this mean?

Although the backend processes the percentage field modifications correctly

And what does this mean?

the site displays incorrect values, particularly in some other rows

When looking at this code, it seems like you update that ri!record multiple times. I don't think this is intentional.

mathieud0001
Genius
Mar 29, 2025 3:39 PM UTC

I'd the problem lies in the way you are doing the update with the indexes. Here's an example of what I think you are trying to achieve.

a!localVariables(
  local!records: {
    a!map(percentage: 1),
    a!map(percentage: 1),
    a!map(percentage: 1)
  },
  local!indexesToUpdate,
  local!caseSubmit,
  {
    a!gridLayout(
      headerCells: { a!gridLayoutHeaderCell(label: "%") },
      rows: a!forEach(
        items: local!records,
        expression: a!gridRowLayout(
          contents: {
            a!textField(
              value: fv!item.percentage,
              saveInto: {
                fv!item.percentage,
                a!save(
                  local!indexesToUpdate,
                  append(local!indexesToUpdate, fv!index)
                )
              }
            )
          }
        )
      )
    ),
    a!buttonArrayLayout(
      buttons: a!buttonWidget(
        label: "Submit",
        saveInto: {
          a!save(
            local!caseSubmit,
            a!localVariables(
              local!casesToUpdate: index(
                local!records,
                local!indexesToUpdate,
                null
              ),
              a!update(
                local!casesToUpdate,
                { "createdOn", "createdBy" },
                { now(), loggedInUser() }
              )
            )
          ),
          a!save(local!indexesToUpdate, null)
        }
      )
    )
  }
)