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
  • Hi Ramp,

    Error is because you are using ri!users in your picker field and while appending save!value refers to ri!users which is of type Dictionary and trying to save in User or Group type variable.

    You should be using fv!item in your code for picker field

    a!pickerFieldUsersAndGroups(
    required: true,
    value: fv!item,
    saveInto: fv!item
    ),

    Please give it a try.

    Thanks
    Nafis Khan
Reply
  • Hi Ramp,

    Error is because you are using ri!users in your picker field and while appending save!value refers to ri!users which is of type Dictionary and trying to save in User or Group type variable.

    You should be using fv!item in your code for picker field

    a!pickerFieldUsersAndGroups(
    required: true,
    value: fv!item,
    saveInto: fv!item
    ),

    Please give it a try.

    Thanks
    Nafis Khan
Children