+ Start a Discussion
Sagar Hinsu 13Sagar Hinsu 13 

Force.com Source Scanner Results FLS Update

Hi All,
I have recently done the security scan of my application. 

I have one class where I am updating the fields. When scan report came it shows FLS update issues
 
global with sharing class CrmExternalDataSchechuleJob implements Schedulable{

    public Database.SaveResult sr {get; set;}
    global CrmExternalDataSchechuleJob() {
        
    }
    global CrmExternalDataSchechuleJob(Database.SaveResult saveResult) {
        this.sr = saveResult;
    }
    global void execute(SchedulableContext ctx) {
        
        Log__c Log = [SELECT id, Name,
                                             ActionType__c,
                                             Imported__c,
                                             LogType__c,
                                             Message__c,
                                             NumberOfRecords__c,
                                             SourceObject__c,
                                             CreatedDate
                                             FROM Log__c 
                                             WHERE id = :sr.getId() Limit 1];
        
        List<CrmPerformanceData__c> crmData = [SELECT id, Name,
                                                          Amount__c,
                                                          CrmCampaign__c,
                                                          CrmLeadSource__c,
                                                          CrmPerformanceDefinition__c,
                                                          Date__c,
                                                          Log__c,
                                                          Number__c
                                                          FROM CrmPerformanceData__c 
                                                          WHERE CreatedDate >= :Log.CreatedDate];
        
        if(crmData.size() > 0) {
            for(CrmPerformanceData__c crm : crmData) {
                crm.Log__c = Log.Id;
            }
            Log.Message__c = 'CRM Data Import Successful - Date ' + system.today().format() + ' Number of Records Imported - ' + crmData.size();
            
            update crmData;
        } else {
            Log.Message__c = 'CRM Data Import Successful - Date ' + system.today().format() + ' Number of Records Imported - 0';
        }
        Log.Imported__c = true;
        Log.NumberOfRecords__c = crmData.size();
        Log.SourceObject__c = 'External CRM';
        
        update Log;
        
    }
}

How do I check for the FLS Update for Log object at Line
Log.Imported__c = true;
Log.NumberOfRecords__c = crmData.size();
Log.SourceObject__c = 'External CRM';
update Log;​


Please ignore if any typing mistake or missing paranthesis.. 
Let me know if something is missing or Am I not clear in the question