[SalesForce] insufficient access rights on cross-reference id when contact created from customer community and before trigger tries to update owner

We are trying to update the contact owner of a new contact created via the customer community in the before trigger and receiving the following error.

insufficient access rights on cross-reference id

enter image description here

The same code works completely fine in the after trigger. The customer profile have read/write access to account and contact in the community sharing setting

enter image description here

Best Answer

I've done a lot of troubleshooting on this... this is what i did to solve all the errors:

Portal user cannot edit own account and cannot create new contacts (portal users cannot own partner accounts)