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
AbAb 

Able to create account from Apex code for which user does not have permission

Hello,

I create a account from Apex code.
Account has 2 record types.

Few profiles do not have access to one of record type.

But still the apex code, creates the account with the record type which is not accessible to the the user.

What can be reason ?
 
Best Answer chosen by Ab
Shashi PatowaryShashi Patowary
Hi,

Apex code runs in System context.This means apex code has not restriction in accessing or creating records. You can read more details at this link -

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm

Please let me know if this is helpful.

Regards,
Shashi

All Answers

Shashi PatowaryShashi Patowary
Hi,

Apex code runs in System context.This means apex code has not restriction in accessing or creating records. You can read more details at this link -

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm

Please let me know if this is helpful.

Regards,
Shashi
This was selected as the best answer
AshlekhAshlekh
Hi,

You need to check the class is running in with sharing or without sharing. And also you need to check the defauld record type for record and for that profile.

-Thanks
Ashlekh Gera