I do know that we can use "without sharing" when we dont want to apply the sharing rules of the current user to set the values, but my class has nothing after access modifiers, just public class className.

But still I am getting this error. Does apex class puts with sharing by default if we just write public class className.

1 Answer 1


The sharing mode of the class only affects which records a user can query, update, or delete. Most profile permissions are still enforced, such as verifying that a record type is valid for a given profile. If the user does not have the record type assigned to them either by their profile or by a permission set, then they may not start a DML operation that changes the record type to that value. Triggers, workflow rules, processes, and flows can change the record type later, but the record type must be valid for the profile at the moment the DML operation is called.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.