function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jarryd Shirley 7Jarryd Shirley 7 

Apex trigger not updating case owner for non-admin user updates

Hello,

I've built an apex trigger (before insert before update) that will pass the case to an apex class, which that will update the owner of a case to either another user or a queue. The apex code performs perfectly for an admin user. When a non-admin user attempts to update the case where it will cause the owner to change to another user, they are given an insufficient privileges error. It was my understanding that apex ran at a system level and ignored user permissions.

I've checked debug logs and I'm not seeing any obvious fails from validation rules. I've also excluded "with sharing" from the apex class.

Can someone provide some insight into this for me?
Manish  ChoudhariManish Choudhari
Hi Jarryd,

It's good that you have removed "with sharing" from class, but did you try including "without sharing" in class signature.

If the issue still persists, can you please paste your code here?

Thanks,
Manish Choudhari
14x Certified Salesforce Architect
Certification link: http://certification.salesforce.com/certification-detail-print?conId=003G000002gRrrEIAS​
My Blog: http://sfdcfacts.com/
Youtube Channel: https://www.youtube.com/SFDCFacts
LinkedIn: https://www.linkedin.com/in/manish-choudhary/
Trailhead: https://trailhead.salesforce.com/en/me/manish-choudhari
Twitter: https://mobile.twitter.com/manish_sfdc
 
Jason Lim 13Jason Lim 13
Hello,

You might want to take a look at the profile permission, see if 'Transfer Case' is enabled for non-admin. 
Jarryd Shirley 7Jarryd Shirley 7
Hello,

Thank you for the advice. 

I'm going to comb through the debug logs again. I'll paste the code if I don't find anything again.

@Jason
You are correct that adding the 'Transfer Case' or 'Transfer Record' permission allows the apex to excute appropriately. I feel like adding this permission should not be necessary though. I would like to limit potential breaches in privileges so I would like to avoid adding that permission unless absolutely necesary. 

Thanks