Apex Programming Language: Create business applications using Apex to extend and improve the usefulness of the Salesforce Platform by Apex Publishing
Author:Apex Publishing [Publishing, Apex]
Language: eng
Format: azw3, epub
Published: 2020-08-29T16:00:00+00:00
' Records has been deleted' );
Undelete Operation
You can undelete the record which has been deleted and is present in Recycle bin. All the relationships which the deleted record has, will also be restored.
Example
Suppose, the Records deleted in the previous example need to be restored. This can be achieved using the following example. The code in the previous example has been modified for this example.
// fetch the invoice created today
List <apex_invoice__c> invoiceList = [ SELECT id, Name , APEX_Status__c,
createdDate FROM APEX_Invoice__c WHERE createdDate = today];
List <apex_invoice__c> updatedInvoiceList = new List <apex_invoice__c> ();
APEX_Customer__c objCust = new APEX_Customer__C();
objCust. Name = 'Test' ;
// Inserting the Customer Records
insert objCust;
for ( APEX_Invoice__c objInvoice: invoiceList) {
if ( objInvoice. APEX_Status__c == 'Pending' ) {
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 values are' + updatedInvoiceList);
// Inserting the New Records using insert DML statement
APEX_Invoice__c objNewInvoice = new APEX_Invoice__c();
objNewInvoice. APEX_Status__c = 'Pending' ;
objNewInvoice. APEX_Amount_Paid__c = 1000 ;
objNewInvoice. APEX_Customer__c = objCust. id;
// DML which is creating the new record
insert objNewInvoice;
System . debug( 'New Invoice Id is ' + objNewInvoice. id);
// Deleting the Test invoices from Database
// fetch the invoices which are created for Testing, Select name which Customer Name
// is Test.
List <apex_invoice__c> invoiceListToDelete = [ SELECT id FROM APEX_Invoice__c
WHERE APEX_Customer__r. Name = 'Test' ];
// DML Statement to delete the Invoices
delete invoiceListToDelete;
system. debug( 'Deleted Record Count is ' + invoiceListToDelete. size());
System . debug( 'Success, ' + invoiceListToDelete. size() + 'Records has been deleted' );
// Restore the deleted records using undelete statement
undelete invoiceListToDelete;
System . debug( 'Undeleted Record count is ' + invoiceListToDelete. size()+ '. This should
be same as Deleted Record count' );
Download
Apex Programming Language: Create business applications using Apex to extend and improve the usefulness of the Salesforce Platform by Apex Publishing.epub
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.
Ada | Ajax |
Assembly Language Programming | Borland Delphi |
C & C++ | C# |
CSS | Compiler Design |
Compilers | DHTML |
Debugging | Delphi |
Fortran | Java |
Lisp | Perl |
Prolog | Python |
RPG | Ruby |
Swift | Visual Basic |
XHTML | XML |
XSL |
Hello! Python by Anthony Briggs(9904)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9785)
The Mikado Method by Ola Ellnestam Daniel Brolund(9769)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8282)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7771)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7756)
Grails in Action by Glen Smith Peter Ledbrook(7685)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7550)
Windows APT Warfare by Sheng-Hao Ma(6767)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6494)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6398)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6361)
Kotlin in Action by Dmitry Jemerov(5048)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4313)
Functional Programming in JavaScript by Mantyla Dan(4037)
Solidity Programming Essentials by Ritesh Modi(3968)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3753)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3695)
The Ultimate iOS Interview Playbook by Avi Tsadok(3670)
