Skip to main content
Known Participant
Apr 4, 2024 12:42 PM UTC
Question

Show members of group using grid

How to list all the members of a group and store them to a local variable to show them in a grid also select multiple members to delete and add the members, using groupmember function?

11 replies

mikes0011
Brainy
Apr 4, 2024 1:09 PM UTC

You can get a list of all members of a group with the function a!groupMembers().  Then you can use this array to serve as the data basis for a grid.  I'm unclear what you mean by "delete and add the members", but you should be able to do various functions all on-form using controls in the grid (like rich text column values with dynamic links perhaps).

The Expression Guru
Known Participant
Apr 4, 2024 1:17 PM UTC

So, by delete and add the members means is, after listing all the members in grid, I wants to add/remove multiple members from within the grid.

mikes0011
Brainy
Apr 4, 2024 1:42 PM UTC

To add new members, I'd go with a person picker below the grid where you can select an individual user then a special button nearby which, upon clicking, adds them to the group.  I would not attempt to do this "in the grid".

To remove individuals, I'd suggest creating a column with a rich text icon and a dynamic link calling the function a!removeGroupMembers() on the username referenced in that row.  You could potentially also enable selection of multiple rows and removing all selected members via a button click, however I'd only go with this approach if the row-by-row solution is *completely* unacceptable.

The Expression Guru
shubhama926776
Brainy
Apr 4, 2024 1:11 PM UTC

Use groupMembers() to retrieve members. Display members in a grid.Add checkboxes for selection. Use removeGroupMembers() to delete selected members. Use addMembersToGroup() to add new members.

शुभम्
Known Participant
Apr 4, 2024 1:25 PM UTC

Thanks,

Can you explain in details how can I use groupMembers(), removeGroupMembers() and addMembersToGroup() using grid

shubhama926776
Brainy
Apr 4, 2024 1:29 PM UTC

Use a!groupMembers(groupId) to store members in a local variable.
Display members and enable selection using a grid with checkboxes.
Use a!filter(members, selected) to get selected members for deletion.
Loop through selected members and use a!removeGroupMembers(groupId, memberId) to delete each.
Use a user picker and a!addMembersToGroup(groupId, userId) to add new members in a loop.
Remember, security clearances are required for modifying groups, and error handling is recommended.

शुभम्
mikes0011
Brainy
Apr 5, 2024 3:24 PM UTC

If you have followup questions, you should stick to your original post (i note some of your replies here seem to have been "spammed" - [mention:115d03e07c2843c691ef69b0951c7286:e9ed411860ed4f2ba0265705b8793d05] can anyone look into that?).  But there's no need for 3 separate posts on it - at the very least, it makes it confusing for us to keep up-to-date with how far you've gotten, and aside from that, makes the front page needlessly cluttery.

The Expression Guru
gus.lines
Employee
May 2, 2024 7:08 PM UTC

Hey Mike, thanks for pointing this out. We will investigate this matter and address it appropriately.

mikes0011
Brainy
May 2, 2024 7:16 PM UTC

thanks - also I just got your PM, but it won't allow me to reply (and it said so only after I'd typed one out).

The Expression Guru