Editable grid having user or group picker with add and remove row features.

Certified Senior Developer

Hi,

We have requirement of creation of GridLayout(editable) grid with one user or group column having add and remove row features. here is the sample code for the same. but we are facing when clicking the "Add item" link like "Expression evaluation error at function 'append' [line 94]: Could not cast from Dictionary to User or Group. Details: CastInvalid".

 

here ri!users is array of User or Group type. Please do the needful to rectify the casting error.

a!sectionLayout(
          label: "Security Group",
          contents: {
            a!gridLayout(
              label: "Members of New Group:",
              totalCount: count(
                ri!users
              ),
              headerCells: {
                a!gridLayoutHeaderCell(
                  label: "Membership"
                ),
                /* For the "Remove" column */
                a!gridLayoutHeaderCell(
                  label: ""
                )
              },
              rows: a!forEach(
                items: ri!users,
                expression: a!gridRowLayout(
                  contents: {
                    a!pickerFieldUsersAndGroups(
                      required: true,
                      value: ri!users,
                      saveInto: ri!users
                    ),
                    /* For the Removal Column*/
                    a!imageField(
                      label: "delete " & fv!index,
                      images: a!documentImage(
                        document: a!iconIndicator(
                          "REMOVE"
                        ),
                        altText: "Remove User or Group",
                        caption: "Remove ",
                        link: a!dynamicLink(
                          value: fv!index,
                          saveInto: {
                            a!save(
                              ri!users,
                              remove(
                                ri!users,
                                save!value
                              )
                            )
                          }
                        )
                      ),
                      size: "ICON"
                    )
                  },
                  id: fv!index
                )
              ),
              addRowlink: a!dynamicLink(
                label: "Add an Item",
                value: {
                  Membership:""
                },
                saveInto: {
                  a!save(
                    ri!users,
                    append(
                      ri!users,
                      save!value
                    )
                  )
                }
              )
            )
          }
        )

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    a!sectionLayout(
              label: "Security Group",
              contents: {
                a!gridLayout(
                  label: "Members of New Group:",
                  totalCount: count(
                    ri!users
                  ),
                  headerCells: {
                    a!gridLayoutHeaderCell(
                      label: "Membership"
                    ),
                    /* For the "Remove" column */
                    a!gridLayoutHeaderCell(
                      label: ""
                    )
                  },
                  rows: a!forEach(
                    items: ri!users,
                    expression: a!gridRowLayout(
                      contents: {
                        a!pickerFieldUsersAndGroups(
                          required: true,
                          value: ri!users[fv!index],
                          saveInto: ri!users[fv!index]
                        ),
                        /* For the Removal Column*/
                        a!imageField(
                          label: "delete " & fv!index,
                          images: a!documentImage(
                            document: a!iconIndicator(
                              "REMOVE"
                            ),
                            altText: "Remove User or Group",
                            caption: "Remove ",
                            link: a!dynamicLink(
                              value: fv!index,
                              saveInto: {
                                a!save(
                                  ri!users,
                                  remove(
                                    ri!users,
                                    save!value
                                  )
                                )
                              }
                            )
                          ),
                          size: "ICON"
                        )
                      },
                      id: fv!index
                    )
                  ),
                  addRowlink: a!dynamicLink(
                    label: "Add an Item",
                    value:"",
                    saveInto: {
                      a!save(
                        ri!users,
                        append(
                          ri!users,
                          save!value
                        )
                      )
                    }
                  )
                )
              }
            )
      

    Use this code. If you do not understand what changes I have made, Kindly get back to me.

  • Hi Aditya, I am using record now. How can I select multiple users at a time in editable grid.

Reply Children
No Data