Member Inclusion with Tick Marks and Non-member Exclusion with Crosses
Facing issue in accurately displaying membership status within groups
Difficulties in correctly identifying group membership.
Seeking assistance.
a!localVariables( local!selectedGroup: ri!initialGroup, local!distinctUsers: getdistinctusers({local!selectedGroup}), local!groupMembers: if( a!isNullOrEmpty(local!selectedGroup), "Please select a group", local!distinctUsers ), local!groupName:a!forEach( items: local!selectedGroup, expression: getgroupnames(fv!item) ), { a!sectionLayout( label: "User And Group Management", contents: { a!pickerFieldGroups( label: "Group Picker", labelPosition: "ABOVE", maxSelections: 5, value: ri!initialGroup, saveInto: ri!initialGroup, ) } ), a!sectionLayout( label: "User Information", contents: { a!gridField( label: "User Grid", labelPosition: "ABOVE", data: rule!GMU_Test(), columns: { a!gridColumn( label: "First and Last Name", value: fv!row['recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstAndLastName}firstAndLastName'], backgroundColor: "NONE", align: "CENTER", width: "NARROW" ), a!forEach( items: local!groupName, expression: a!gridColumn( label: fv!item, value: if( contains( local!groupMembers, fv!row['recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_username}username'] ), a!richTextDisplayField( value: a!richTextIcon( icon: "check", color: "POSITIVE" ) ), a!richTextDisplayField( value: a!richTextIcon( icon: "times", color: "NEGATIVE" ) ) ), align: "CENTER", width: "NARROW" ) ) } ) } ) } )
Discussion posts and replies are publicly visible
What do you mean with?
Priyanshu Bhavsar said:Difficulties in correctly identifying group membership
When selecting a group, the grid listing all members does not accurately reflect their membership status. Initially, all members are displayed in the first row. Upon selecting a group, the aim is for the grid to indicate members of the selected group with tick marks to signify their presence, and non-members with crosses to denote their absence.
For me, it seems like local!groupMembers always contains the members of all groups.
To solve this, inside the individual columns, you need to detect membership for each user, but for the specific group of that columns only.
One option might be to use a!localVariables inside the foreach to create a nested variable context for reach column. Then get the members of that group and change your logic to work with this new variable.
Another option is to use a!isUserMemberOfGroup() to check for each combination of user and group. Then you do not need the local variables in the foreach.
Keep in mind, that your grid can become large and slow for many groups/users.
Thanks for sharing these solutions! Also, a good reminder about performance impacts with large datasets.