I have a unique requirement in communities but I will explain it simple. I wanted to change the ownership of account to internal user as soon as it is created by a community user and grant READ access to the user who created it so that community user can see it. I have got a working solution using a scheduled batch process but wanted it in real time using a Trigger. I tried different options but always endup with some kind exception.
This is what I am doing in the trigger.
- Change ownership to internal user. Just setting account.Owner to internal user id.
- Create a new Accountshare with RowCause Manual using Apex to the user who created it.
I got INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id:
I even tried to delete existing share and create new one but could not succeed.
Would appreciate any insight on how to implement this in trigger?