I have a list of sObjects. In this list I have records of Account,Contact and Opportunity which needs to be updated. so before updating the list I am doing CRUD check on Account , Contact and Opportunity like below:
List<sObject> lstOfSObjects = new List<sObject>();
lstOfSObjects.add(new Account(.......));
...
lstOfSObjects.add(new Contact(.......));
...
lstOfSObjects.add(new Opportunity(.......));
...
if (!Schema.sObjectType.Account.isUpdateable()) {
return...
}
if (!Schema.sObjectType.Contact.isUpdateable()) {
return...
}
if (!Schema.sObjectType.Opportunity.isUpdateable()) {
return...
}
update lstOfSObjects;
Even if I am checking CRUD check for every sObject still Apex PMD is throwing an error at the update DML saying : Validate CRUD before DML Operation.
Any help?