Skip to main content
March 28, 2025
Question

#Unabable to update values in SIte level

  • March 28, 2025
  • 3 replies
  • 0 views

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
March 29, 2025

Could you explain the problem  a little bit please?

stefanhelzle0001
March 29, 2025

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
March 29, 2025

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