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
@ M  Coder@ M Coder 

LWC : "Validate CRUD permission before SOQL/DML operation (rule: Security-ApexCRUDViolation)"

I am getting this warning in VS code due to my which my simple apex class is not getting called in JS when i do a import . 

my apex class: 
public with sharing class CarController {

@AuraEnabled(Cacheable=true)
    public static List<Car__c> getCars(){
    
    return[SELECT Id, Name, MSRP__c, Description__c,Category__c, Picture_URL__c FROM Car__c];
    }
}

warning comming: 
Validate CRUD permission before SOQL/DML operation (rule: Security-ApexCRUDViolation)", 

My analysis: I am doing this in my own org via system admin . All the fields have FLS for the profile and class access at profile level. 

if i change the soql to 
 return[SELECT Id, Name, MSRP__c, Description__c,Category__c, Picture_URL__c FROM Car__c with SECURITY_ENFORCED];
       
then also i am unable to access my class in js import statement . 

can anyone please modify it what has to be done 

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Using the below Can you confirm if you are getting the same error?
 
return[SELECT Id, Name, MSRP__c, Description__c,Category__c, Picture_URL__c FROM Car__c with SECURITY_ENFORCED];

Thanks,
​​​​​​​
@ M  Coder@ M Coder
Hi Sai praveen , 
Thanks for quik reply 

I am not getting the warning but i am unable to access my class in JS  to import. if i write it manually my component fails to load with no error . 

User-added image