If I encounter a system user account during round robin assignment this method is called in an extension helper class:
function assignToNonSystemUser_Ext(group : Group) : void {
group.Users = group.MembersNoSystemUsers.where(\user -> user.User.Credential.Active and user.User.VacationStatus == VacationStatusType.TC_ATWORK)
this.assignUserByRoundRobin(false, group)
}
The issue is this is saving the filtered list of users to the DB which removes my system user from my group altogether.
I was expecting it would only operate on the group temporarily and not save the filtered list of users to my database.
The line below is causing the issue and this doesn't seem to be the right way to do an assignment.
group.Users = ......
This effectively calls the setter on the
Group
entity and updates the references of users that belong to the group. Since you are passing the reference to the group, any changes to the parameter variable will update the original object. TheassignUserByRoundRobin
function doesn't expect you to pass modified groups to it. Instead, it needs an existing group that has been set up as per administration data.Since you are looking to match certain attributes on the
User
entity while doing the assignment, you can either build a new AssignmentStrategy class that implementsDynamicUserAssignmentStrategy
or check ifassignByUserAttributes( criteria, true, group)
can support your use case but you may have to configure the attributes you are trying to check and pass in the attribute name and value to the criteria before calling the assignment funciton.