Prevent CRUD/FLS violation - isAccessible()
There are certain security tests which salesforce recommends before allowing an application to be used. These tests include permissions, XXS vulnerabilities, etc. One of these is regarding the accessibility of the fields which are being retrieved in your code. This code snippet will help you check the accessibility of your fields included in a SOQL query. IsAccessible() This function of DescribeSObjectResult class, verifies that the logged-in user has permission to access the field before your code retrieves the field from an object via query. Code Snippet : public static Boolean isFieldsAccessible(Map<String, Set<String>> objectFields) { Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); Integer globalFlag = 0; for (String objectName : objectFields.keySet()) { Integer flag = 0; ...