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
Diwakar G 7Diwakar G 7 

ApexCRUDviolation Fix

Hi, 

How to fix ApexCRUDViolation for inner query. Below is the query.
proposal = [select Id, Name,(Select Id From PQConfig__Configurations__r) From Proposal__Proposal__c Where Proposal__Opportunity__c =:lead.ConvertedOpportunityId];
I tried the below one to fix the violation. Violation is fixed.
if(!Schema.sObjectType.Proposal__Proposal__c.isQueryable() && !Schema.sObjectType.PQConfig__Configurations__r.isAccessible()) {
     return null;
     }
But, PQConfig__Configurations__r is not an object. Getting error while saving class in Salesforce. Please help me to fix the violation.

Thanks and Regards,
Diwakar G

 
Diwakar G 7Diwakar G 7

Hi, 

Please help me to fix the issue.

Thanks and Regards,
Diwakar G

Bishwambhar Sen 16Bishwambhar Sen 16
Try this select Id, Name,(Select Id From PQConfig__Configurations__r) From Proposal__Proposal__c Where Proposal__Opportunity__c =:lead.ConvertedOpportunityId WITH security_enforced

This will resolve the Apex PMD error. Mark this as best answer if it helped.