Objective is to share a 'User Group' with itself. Following code works fine to share a 'User' with a 'User Group', but not for sharing 'User Group'.

  UserShare groupShr = new UserShare();
  groupShr.UserId = toShareId;//works for ID of User, not for ID of User Group
  groupShr.UserOrGroupId = spaceGroupId;
  groupShr.UserAccessLevel = 'Read';

  insert groupShrList;

Exception thrown if above code tries to share user group is FIELD_INTEGRITY_EXCEPTION, User ID: id value of incorrect type: 00GF0000004ucwlMAA: [UserId]: Trigger.TriggerName: line 30, column 1

Is it possible to share user group?

1 Answer 1


The documentation clearly states that the userId has to be the Id of the user being shared. So you cannot set it to the groupId.

The other work around is: you get the users in the group, then itereate thru all the users and then share the records.

  • Yes, User ID has to be ID of the User & not of the group. That's why the question- is it even possible to share user group? Commented Aug 19, 2014 at 6:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .