+ Start a Discussion
SAI CHARAN MADUGULASAI CHARAN MADUGULA 

Query: FLS Update

Hello All,

I done the security scanning yesterday i got this issues in some classes.i have mentioned one classes below.please can anybody help me for this.

Query: FLS Update

Object: current_week_severe__c in file: /classes/AccountTriggerHandler.cls
L 209: newAccount.Current_Week_Severe__c = mapOfAccountAndSevereCurrentCount.get(newAccount.Id);
Object: add in file: /classes/AccountTriggerHandler.cls
L 262: listOfAccountsToUpdate.add(newAccount);
Object: listofaccountstoupdate in file: /classes/AccountTriggerHandler.cls
L 265: if(isUpdateAccounts && (listOfAccountsToUpdate!=null && !listOfAccountsToUpdate.isEmpty() && listOfAccountsToUpdate.size()>0)){
Object: listofaccountstoupdate in file: /classes/AccountTriggerHandler.cls
L 268: update listOfAccountsToUpdate;
suresh dupadasuresh dupada

at 209th line your are assigning a value from mapofAccountAndServereCurrentCount.get(newAccount.id), right here you are going to assigned to "newAccount.Current_Week_Severe__c" field and then finally newAccount is going to update at lineNumber 268, so here you go to provide security as below

1. if newAccount is an Account Object Instance, and then "Current_Week_Severe__c" is field in it,
if(Schema.SobjectType.Account.fields.Current_Week_Severe__c.isupdateable())
             newAccount.Current_Week_Severe__c = mapOfAccountAndSevereCurrentCount.get(newAccount.Id);

SAI CHARAN MADUGULASAI CHARAN MADUGULA
Hi Suresh is this correct

if(isUpdateAccounts && (listOfAccountsToUpdate!=null && !listOfAccountsToUpdate.isEmpty() && listOfAccountsToUpdate.size()>0)){
            System.debug('Before updating list'+listOfAccountsToUpdate);
            try{
            
            if(Schema.SobjectType.Account.fields.current_week_severe__c.isupdateable()) {
             newAccount.current_week_severe__c = mapOfAccountAndSevereCurrentCount.get(newAccount.Id);
             

              {  
                update listOfAccountsToUpdate;
                            
             
               }  
               
            }
            catch(DMLException e){
                for(Account accRec : listOfAccountsToUpdate){
                    System.debug('Error in Updating Account:'+ accRec + ':' + e.getMessage());
                }
            }
        }
    }