You need to sign in to do that
Don't have an account?
chikku
Unable to insert old and new values in apex trigger
Hi,
I have an object called log__c in that fields have Description__c, Action__c
with Lookup with Contact object, when I change phone field of contact object then in log__c object of Description__c field should be inserted that old phone is 123 and new phone 456 like that I need
Please help
I have an object called log__c in that fields have Description__c, Action__c
with Lookup with Contact object, when I change phone field of contact object then in log__c object of Description__c field should be inserted that old phone is 123 and new phone 456 like that I need
trigger oldvalue on Contact (after insert,after update, before insert) { Log__c logtime =new Log__c(); logtime=[Select id,Name,Contact ,Description__c,Action__c FROM Log__c ]; if(trigger.isbefore && trigger.isUpdate ){ for(integer i=0; i<trigger.new.size();i++){ if(Trigger.New[i].Phone!=Trigger.Old[i].Phone){ logtime.Action__c ='check'; logtime.Description__c +='\n phone number old value='+Trigger.Old[i].phone+ ' New phone ' + Trigger.New[i].phone; insert logtime; } } } }
Please help
It throws error like this Method does not exist or incorrect signature: void Add(List<Log__c>) from the type List<Log__c>
It works but there is some error, it is updating more times and there is nothing update in Description__c is empty
Action__c is title label name,
Can you please help it
There is any way to avoid this issue
there is any solution there?