You need to sign in to do that
Don't have an account?
balaji aluri 16
While updating any record i need to take backup that record details in Test obj.
Hi, I am new to salesforce development. We are having 'Payee__c' Object in our org and while i am updating any Payee record that previous values should be stored in "Test__c' Obj with a new record creation. Pls go with following code for reference. The code is executing with no errors, but while updating Payee record the old values not storing in Test obj. Quick response will be appreciated.
trigger TestRecordInsert on Payee__c (Before Update) {
List<Test__c> test= new List<Test__c>();
For(Payee__c p:Trigger.old){
Test__c t=new Test__c();
t.Amount1__c = p.Amount__c;
t.Payee_amount__c = p.Payee_amount__c;
t.payee_name__c = p.payee_name__c;
test.add(t);
}
Insert test;
}
trigger TestRecordInsert on Payee__c (Before Update) {
List<Test__c> test= new List<Test__c>();
For(Payee__c p:Trigger.old){
Test__c t=new Test__c();
t.Amount1__c = p.Amount__c;
t.Payee_amount__c = p.Payee_amount__c;
t.payee_name__c = p.payee_name__c;
test.add(t);
}
Insert test;
}
I tested it for case and opp and don't find any issues. Please make sure that you added all the required fields for Test record in the above code.