0

Suppose I have Account as Private OWD (Sharing model).

I also have a My_Custom__c custom object that has a Lookup field to Account.

Provided I know the Id of a valid Account that I do not have access to, when i try to insert a new My_Custom__c referencing that Account Id, I get a INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY error.

Is it possible to somehow allow to create those records?

As a bit more context:

Imagine in one browser a user started editing My_Custom__c and in another browser some other user removed our first guy's access to the Account. i want the record save to succeed, even though they could no longer start that process from scratch.

1 Answer 1

1

It's not directly possible, no. This is because if you were allowed to save the record, then Implicit Sharing might grant access to the Account for that user, so you'd accidentally provide sharing you didn't mean to. The system prevents this from happening by throwing this error. I believe you could set up a Platform Event, set a trigger on it, and then have some automation fire this event when a child record is created. However, again, if you attempt to bypass this error, you may cause records to be exposed inadvertently to the user.

3
  • Um, or simply do the DML operation in a "without sharing" class (if you don't use some form of implicit sharing in your org that would be affected)? This would, obviously, not be using the standard save functionality in a Salesforce form...
    – Phil W
    Commented May 18, 2020 at 13:51
  • @PhilW As far as I can tell, this validation can't be bypassed using "without sharing." It appears to be validated at the database level, along with required fields, data types, etc. I had problems with this in a trigger some years ago, I never did find a way to bypass it, except to not set a value at all.
    – sfdcfox
    Commented May 18, 2020 at 14:03
  • That is not my experience. Adding without sharing to the class performing the DML negates this error.
    – Phil W
    Commented May 18, 2020 at 19:47

You must log in to answer this question.

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