How to remove member from particular group, from the grid column using dynamicLink ?

a!localVariables(
  local!selectedGroup: ri!initialGroup,
  local!actionTaken: if(
    isnull(ri!btnAction),
    false,
    or(ri!btnAction = "ADD", ri!btnAction = "MOVE")
  ),
  local!distinctUsers: if(
    a!isNullOrEmpty(local!selectedGroup),
    "Please select a group",
    a!flatten(
      a!forEach(
        items: local!selectedGroup,
        expression: a!localVariables(
          local!group: fv!item,
          a!forEach(
            items: getdistinctusers({ fv!item }),
            expression: a!map(
              id: fv!index,
              Group: local!group,
              Members: fv!item
            )
          )
        )
      )
    )
  ),
  local!pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 10),
  {
    a!sectionLayout(
      label: "User & Group Management",
      contents: {
        a!pickerFieldGroups(
          label: "Pick Groups",
          labelPosition: "ABOVE",
          maxSelections: 5,
          value: ri!initialGroup,
          saveInto: {
            ri!initialGroup,
            a!save(
              {
                ri!btnAction,
                ri!userToRemove,
                ri!userToRemove,
                ri!userToAdd,  
                local!selectedGroup
              },
              null
            )
          },
        )
      }
    ),
    a!sectionLayout(
      label: "Group members",
      contents: {
        a!columnsLayout(
          columns: a!forEach(
            items: local!selectedGroup,
            expression: a!columnLayout(
              a!gridField(
                label: "",
                labelPosition: "ABOVE",
                data: index(
                  local!distinctUsers,
                  wherecontains(
                    touniformstring(fv!item),
                    touniformstring(local!distinctUsers.Group)
                  )
                ),
                columns: {
                  a!gridColumn(
                    label: group(
                      groupId: togroup(fv!item),
                      property: "groupName"
                    ),
                    value: fv!row.Members
                  ),
                  a!gridColumn(
                    value: a!richTextDisplayField(
                      value: a!richTextIcon(
                        icon: "times",
                        caption: "Remove User",
                        color: "NEGATIVE",
                        size: "MEDIUM",
                        link: a!dynamicLink(
                          value: fv!row.Members,
                          saveInto: ri!userToRemove
                        )
                      )
                    ),
                    width: "ICON"
                  )
                },
                pagingSaveInto: local!pagingInfo
              )
            )
          ),
          showDividers: true
        ),
        a!linkField(
          labelPosition: "COLLAPSED",
          links: {
            a!dynamicLink(
              label: "+ Add Users to Selected Group",
              value: "ADD",
              saveInto: {
                ri!btnAction,
                a!save(ri!addedtoGroup, ri!initialGroup)
              }
            )
          },
          showWhen: not(local!actionTaken)
        ),

      }
    ),
    a!sectionLayout(
      label: "Add Users",
      contents: {
        a!pickerFieldUsers(
          label: "Users to Add",
          value: ri!usertoAdd,
          saveInto: a!save(
            ri!usertoAdd,
            if(isnull(save!value), {}, save!value)
          ),
          required: true
        )
      },
      showWhen: ri!btnAction = "ADD"
    ),
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: if(
            ri!btnAction = "ADD",
            "Add Users",
            "Move User"
          ),
          submit: true,
          style: "SOLID"
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancel",
          value: null,
          saveInto: { ri!btnAction, ri!initialGroup,  },
          style: "OUTLINE",
          showWhen: local!actionTaken
        )
      },
      showWhen: local!actionTaken
    )
  }
)

I'd like to remove a specific member from the chosen group using the dynamicLink and add a member to all selected groups.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    a!dynamiclink(
    saveInto: a!removeGroupMembers(
                                group: "Your Group",
                                members: fv!row.Members/"Current member you want to remove",
                              
                              ))
                              
                              
                            
    a!dynamiclink(
    saveInto: a!addMembersToGroup(
                                group: "Your Group",
                                newMembers: /"Current member you want to add",
                              
                              ))

    Use a!removeGroupMembers() and a!addMembersToGroup() in save into param of dynamic link. Interface Configuration needs to look like above. 

    I suggest going with initiating a Process cause it helps in future references (It provides history of who did it). In process model use respective smart services

Reply
  • 0
    Certified Senior Developer

    a!dynamiclink(
    saveInto: a!removeGroupMembers(
                                group: "Your Group",
                                members: fv!row.Members/"Current member you want to remove",
                              
                              ))
                              
                              
                            
    a!dynamiclink(
    saveInto: a!addMembersToGroup(
                                group: "Your Group",
                                newMembers: /"Current member you want to add",
                              
                              ))

    Use a!removeGroupMembers() and a!addMembersToGroup() in save into param of dynamic link. Interface Configuration needs to look like above. 

    I suggest going with initiating a Process cause it helps in future references (It provides history of who did it). In process model use respective smart services

Children