R34516 Group - Update Group Name On Member Change

Code R34516
Entity Communities.Social.Groups Entity
Name UpdateGroupNameOnMemberChange
Attribute -
Layer Back-End
Events Commit
Record State Inserted, Deleted
Priority Normal
Modify YES
Action if (SocialGroup.Name == null)
, then set SocialGroup.Name = {GroupMember.User.Name(first name)}

if ((SocialGroup.Name != null) AND (the group name is NOT user-defined*))
, then check
if (count GroupMembers after change <= 3)
, set SocialGroup.Name = GroupMember.User.Name(first name) of all GroupMembers after change, separated with comma and sorted ascending by name
else set SocialGroup.Name = get TOP2(GroupMember.User.Name(first name) of all GroupMembers after change, separated with comma and sorted ascending by name) +{GroupMembers.Count - 2}


* check if the group name is user defined:


if ((count GroupMembers before change <= 3) AND (SocialGroup.Name.DatabaseValue != GroupMember.User.Name(first name) of all GroupMembers before the change, separated with comma and sorted ascending by name))
, then TRUE


if ((count GroupMembers before change > 3) AND (SocialGroup.Name.DatabaseValue != get TOP2(GroupMember.User.Name(first name) of all GroupMembers before change, separated with comma and sorted ascending by name) + {GroupMembers.Count - 2}))
, then TRUE
Description If a social group name is not user-defined and a group member is added or removed from this group, the name of the group is changed accordingly.

If the group members are 3 or less, the name is formed as a comma separated list from the members' first names (sorted ascending).
E.g.: Anna, Ben, Chris

If the group members are more than 3, the name is formed as a comma separated list from first names of the first two members (sorted ascending) and the count of the rest of the members.
E.g.: Anna, Ben, +2
Message -
Version Introduced: 2023
Revocable NO

* For more information about the Business Rules Documentation Template and a short explanation of each column, see topic System Business Rules.