1

I have used WITH SECURITY_ENFORCED in the query still getting this error.Can someone suggest a solution?

 Public void freezeMethod (){
        disabledFreez = true;
        
        try{
            
            Direct_Commission__c dcObj = new Direct_Commission__c();
            If(String.isNotBlank(TermName)){
                dcObj.Term__c = TermName;
            }
            
            
            Insert dcObj; <-- Error on this line
2

Hello SECURITY_ENFORCED enforced Field-Level security. CRUD is object-level security. You need to check for the User's ability to Create/Read/Update/Delete SObject itself

if (!SObjectType.Direct_Commission__c.isCreateable()) {
  // handle no access case
}
4
  • That your user has no ability to Insert Direct_Commission__c
    – ytiq
    Nov 17 '20 at 7:33
  • ytiq Thanks it worked. But I used !Direct_Commission__c.SObjectType.getDescribe().isCreateable(). Nov 17 '20 at 7:34
  • Whatever you prefer)
    – ytiq
    Nov 17 '20 at 7:35
  • Glad I was able to help
    – ytiq
    Nov 17 '20 at 7:36

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.