I have following code to update a list of Events.

if(lstEventToUpdate.isEmpty() == false){
        System.debug('Before database update: '+lstEventToUpdate);
        List<Database.SaveResult> lstSaveResult = Database.update(lstEventToUpdate, false);

        for(Database.SaveResult aResult: lstSaveResult){
            System.debug('The aResult.isSuccess() is :'+aResult.isSuccess());
            if(aResult.isSuccess() == false){
                for (Database.Error err : aResult.getErrors()){
                    System.debug('Error while updating Event (Meeting) id: '+aResult.getId()+' Message: '+err.getMessage());
    }catch(Exception e){
        System.debug('Exception while updating the event: '+e.getMessage());

After first System.debug, none of the other debug logs are getting printed. I went through the similar post on this website here Problem with Database.update() and the code is supposed to work. Am I missing something?


I don't think the Apex is "erroring" out. The rest of the code just isn't being executed because lstSaveResult is most likely empty. Put a debug statement that will display the size of your list to verify that this is the case. Once you verify that, look into why your list could be empty. (I would've just commented this, but my reputation is too low)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.