function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
duubduub 

Auto Add User to a Collaboration Group Member Object - issue with Duplicate error

Hi.

 

I have an issue with the Collaboration Group Member object, if I try and add an Already existing member to a group that they are in, I get a duplicate error:

 

caused by: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

 

1. Is there a simple solution for this? Why can't it ignore the insert, I could do a try catch, but this is part of a bulk insert or update.

 


 

kyle.tkyle.t

The solution would be to loop through the list of members that are being added to the group and if they don't already exist then simply add them to a new list that you insert.