The use case is a
trigger calls(enqueues) a
Queueable job. The code is failing and I did some debugging and figured out that it is running in user context. I thought asynchronous jobs run in system context. Is it possible to run a
Queueable job in system context?
This is my use case
A partner community user creates an account and we need to transfer the ownership to internal user and then grant Read permission to community user who created it. In the Account trigger, I change the owner to internal user but can't insert a row into AccountShare due to the error "INSUFFICIENT_ACCESS_ON_ CROSS_REFERENCE_ENTITY". After debugging, I realized that the community user already has access to account because the record with new owner in not committed yet. So in the trigger I change the ownership and in the queuable job, I am inserting a row into AccountShare for community user but I still get "INSUFFICIENT_ACCESS_ON_ CROSS_REFERENCE_ENTITY" error in the queueable job.