Why is my filter that removes system users removing system users and saving to database?

55 views Asked by At

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.

2

There are 2 answers

1
Abhijay Kumar On

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. The assignUserByRoundRobin 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 implements DynamicUserAssignmentStrategy or check if assignByUserAttributes( 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.

0
SteveDrippsCentricConsulting On

If your extension function is called from an assignment rule, then any changes to the entity objects will be persisted in the database. The persistence of the Users in the group would also occur if called from a PCF which already had an implicit bundle created.

What Guidewire product/version are you working on? What entity is this function an extension of? If you post some more details I will update my answer.