Interface Definition: Expression evaluation error at function a!forEach [line 102]: Error in a!forEach() expression during iteration 1: Expression evaluation error : Invalid index: Cannot index property 'firstName' of type Text into type Number (In

2 grids, the first is for selecting rows, and the second is a read only for presenting the first and last name of the row selected.

a!localVariables(
  local!selection,
  local!selectedEmployees,
  {
  a!columnsLayout(
    columns: {
      a!columnLayout(
        contents: {
          a!gridField(
            label: "Read-only Grid",
            labelPosition: "ABOVE",
            data: a!queryEntity(
              entity: cons!EMPLOYEE_ENTITY,
              query: a!query(
                selection: a!querySelection(
                  columns: {
                    a!queryColumn(
                      field: "id"
                    ),
                    a!queryColumn(
                      field: "firstName"
                    ),
                    a!queryColumn(
                      field: "lastName"
                    ),
                    a!queryColumn(
                      field: "department"
                    ),
                    a!queryColumn(
                      field: "startDate"
                    )
                  }
                ),
                pagingInfo: fv!pagingInfo
              ),
              fetchTotalCount: true
            ),
            columns: {
              a!gridColumn(
                label: "First Name",
                sortField: "firstName",
                value: fv!row.firstName
              ),
              a!gridColumn(
                label: "Last Name",
                sortField: "lastName",
                value: fv!row.lastName
              ),
              a!gridColumn(
                label: "Department",
                sortField: "department",
                value: a!richTextDisplayField(
                  value: {
                    a!richTextItem(
                      text: {fv!row.department},
                      linkstyle: "INLINE",
                      color: if(fv!row.department="Sales", "SECONDARY", null),
                      style: {
                        "EMPHASIS"
                      }
                    )
                  }
                )
              ),
              a!gridColumn(
                label: "Start Date",
                sortField: "startDate",
                value: fv!row.startDate,
                align: "END"
              )
            },
            pagesize: 5,
            initialsorts: {
              a!sortInfo(
                field: "lastName"
              )
            },
            selectable: true,
            selectionvalue: local!selection,
            selectionsaveinto: {
              local!selection,
              /* This save adds the full rows of data for items selected in the most recent user interaction to local!selectedEmployees. */
              a!save(local!selectedEmployees, append(local!selectedEmployees, fv!selectedRows)),
              /* This save removes the full rows of data for items deselected in the most recent user interaction to local!selectedEmployees. */
              if(rule!APN_isEmpty(fv!selectedRows),{},
              a!save(local!selectedEmployees, if(rule!APN_isEmpty(fv!deselectedRows),local!selectedEmployees,difference(local!selectedEmployees, fv!deselectedRows)))
              )
            }
          ,
            selectionrequired: false,
            disablerowselectionwhen: fv!row.department="Sales",
            validations: {}
          )
        },
        width: "WIDE"
      ),
      a!columnLayout(
        contents: {
          a!richTextDisplayField(
            label: "Selected Employees",
            labelPosition: "ABOVE",
            value: a!forEach(
              items: local!selectedEmployees,
              expression: {
              a!richTextIcon(
                icon: "user-circle-o"
              ),
              " "& fv!item.firstName & " " & fv!item.lastName,
              char(10)
              }
            )
          )
        }
      )

        }
      )
    }
  )

  Discussion posts and replies are publicly visible