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'
Issue:
- I get DML exception when I try to Apex share records to a Group ID on the custom object 'MyObject__c'
Question:
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