function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger createBackup on Account (after delete) { if(trigger.isDelete && trigger.isAfter) { List<My_Backup__c> lstToInsrt = new List<My_Backup__c>(); for(Account deletedAcc : trigger.old) { system.debug('deletedAcc '+deletedAcc ); My_Backup__c backup = new My_Backup__c(); backup.Name = deletedAcc.name; lstToInsrt.add(backup); system.debug('backup '+backup); } if(lstToInsrt.size()>0) { insert lstToInsrt; system.debug('list'+lstToInsrt); } } }
trigger tableStudentTrigger on Table_Student__c (After Delete) { if(Trigger.isAfter && Trigger.isDelete){ tablestudentTriggerhandler.studentBackup(trigger.old); } } public class tablestudentTriggerhandler { public static void studentBackup(List<Table_Student__c> studentList){ try{ List<Table_Student_backup__c> backupList=new List<Table_Student_backup__c>(); for(Table_Student__c studentObj:studentList){ Table_Student_backup__c backupObj=new Table_Student_backup__c(); backupObj.Name=studentObj.Name; backupList.add(backupObj); } if(!backupList.isEmpty()){ insert backupList; } system.debug('studentList==>'+backupList); }catch(Exception e){ system.debug('error is =>'+e.getMessage()+' at line =>'+e.getLineNumber()); } } }
You can try checking the below trigger snippet code and modify it as per your use case.
Please do note this is a sample code and you need to modify it as per your use scenario and names in the org.
>> reference: https://developer.salesforce.com/forums/?id=906F0000000MGYgIAO
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
please find the solution below
If you find this solution is helpful for you please mark best answer.