Requirement: I want to be able to have private OWD on the objects and share its access to groups/queue.

What works:

  • I'm able to Apex share records to a queue to a vendor packaged object 'VendorObject__c'
  • I'm able to Apex share records to a User ID to a custom object 'MyObject__c'


  • I get DML exception when I try to Apex share records to a Group ID on the custom object 'MyObject__c'

Why does it work on the vendor custom object and not my custom object?

Replication Scenario: I ran SOQL to extract the IDs from Group and User then plug it into the Apex below, it works with User ID but has DMLException on Group ID. Why?

Select Id, Name from Group order by Name

Select Id, Name from User order by Name

Weld_Inspection__Share wiShare = new Weld_Inspection__Share(ParentId = 'a0J2f0000018zIBEAY', 
                                                      UserOrGroupId ='00G2f000001hUCFEA2',
                                                      AccessLevel = 'Read', 
                                                      RowCause = 'Manual');
insert wiShare;

If I run the insert with a value from User, it works.

If I run the insert with a value from Group, I get this error

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown (invalid user or group: 00G2f000001hUCF): [unknown]

Thank you

  • Do you have any members in this group ? if so, are those members internal users, or any customer/partner users? Oct 22, 2021 at 15:36
  • Yes. I have members in the group and they are all internal users. The same group worked on the vendor custom object but not my custom object?
    – Kaliforce
    Oct 22, 2021 at 15:51
  • What happens if you try to manually set sharing in the UI using the Sharing button? Oct 22, 2021 at 20:48
  • Good point. UI showed Group != Queue. Technically, it's a record in Group object with Type = Queue or Regular. The reason I was able to share the vendor custom object with a Queue may have something to do with it going through Approval Process and I configured its relation to QueueSObject. So have to basically share to Public Group instead of directly to Queue. Thank you!!!
    – Kaliforce
    Oct 22, 2021 at 21:27

1 Answer 1


Thanks to David Cheng's prompt. The answer is to share records to Public Group (record in Group object with Type = Regular instead of Type = Queue). It worked for vendor custom object records because that object is configured to go through Approval Process and Apex related the Queue to the QueueSObject and the vendor custom object.

You must log in to answer this question.

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