Salesforce Platform Developer I Certification Guide by Jan Vandevelde

Salesforce Platform Developer I Certification Guide by Jan Vandevelde

Author:Jan Vandevelde [Jan Vandevelde]
Language: eng
Format: epub
Tags: COM005000 - COMPUTERS / Enterprise Applications / General, COM048000 - COMPUTERS / Systems Architecture / Distributed Systems and Computing, COM005030 - COMPUTERS / Enterprise Applications / Business Intelligence Tools
Publisher: Packt Publishing
Published: 2019-05-23T06:04:00+00:00


// we perform only the operation if there are records in the list

if (lstAccounts.size() > 0){

// the short notation of the DML statement

try {

delete lstAccounts;

System.debug(String.valueOf(lstAccounts.size()) + 'accounts deleted');

} catch (DMLException ex){

System.debug(ex.getMessage());

}

}

This is the code to use if you need to delete the accounts through the database operations:

Date dueDate = Date.today().addYears(-1); // today minus 1 year

List<Account> lstAccounts = new List<Account>([SELECT Id FROM Account WHERE LastModifiedDate < :dueDate]);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.