+ Start a Discussion

Give Community User Access to Case he/she Created when Case is Reassigned Using Assignment Rules

We have a community where community users can open cases. We are inserting the case via Apex which changes the owner due to using the default case assignment rule:

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
dmo.EmailHeader.triggerAutoResponseEmail = false;

insert caseRecord;
Without adding a CaseShare record, the community user will no longer be able to access the newly created case. However, when inserting the CaseShare record, we cannot get around this error:

Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

Here's a snippet of adding the CaseShare record. We've tried this in the above class marked as "without sharing", in a future method from a trigger, with and without also adding an AccountShare record.

insert new CaseShare(
    CaseAccessLevel = 'Read',
    CaseId = c.Id,
    UserOrGroupId = c.CreatedById
Any help would be much appreciated.
Best Answer chosen by trmp

All Answers

Apparently share records cannot be assigned to community users.
This was selected as the best answer