forked from deepikakhanna/SalesforcePlatformDeveloper1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial5UpdateDMLOperation
More file actions
21 lines (16 loc) · 846 Bytes
/
tutorial5UpdateDMLOperation
File metadata and controls
21 lines (16 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//http://mytutorialrack.com/
//Check the complete course here https://mytutorialrack.com/salesforce-platform-developer-1-certification-course/
//fetch the invoices created today, Note, you must have at least one invoice created today
List<apex_invoice__c> invoiceList = [SELECT id, Name, APEX_Status__c, createdDate FROM APEX_Invoice__c];
//create List to hold the updated invoice records
List<apex_invoice__c> updatedInvoiceList = new List<apex_invoice__c>();
for (APEX_Invoice__c objInvoice: invoiceList) {
if (objInvoice.APEX_Status__c !='Paid') {
objInvoice.APEX_Status__c = 'Paid';
updatedInvoiceList.add(objInvoice);
}
}
//DML Statement to update the invoice status
update updatedInvoiceList;
//Prints the value of updated invoices
System.debug('List has been updated and updated value of records are'+updatedInvoiceList);