You need to sign in to do that
Don't have an account?
Disha Thakur
Hi, I am trying to update birthdate of most recent contact on Account. It should work on insert and update. It is not showing error but it is not working. What should I do?
trigger BirthdateTrigger on Account (after insert, after update) {
List<Account> acc= new List<Account>();
if(trigger.isInsert || trigger.isUpdate)
{
acc = [select Id,(select Birthdate from Contacts ORDER BY CreatedDate DESC LIMIT 1) from Account where Id IN :trigger.new];
for(Account a : acc)
{
for(Contact c : a.Contacts)
c.Birthdate = Date.newInstance(2000,06,12);
System.debug('Birthdate updated');
}
}
}
List<Account> acc= new List<Account>();
if(trigger.isInsert || trigger.isUpdate)
{
acc = [select Id,(select Birthdate from Contacts ORDER BY CreatedDate DESC LIMIT 1) from Account where Id IN :trigger.new];
for(Account a : acc)
{
for(Contact c : a.Contacts)
c.Birthdate = Date.newInstance(2000,06,12);
System.debug('Birthdate updated');
}
}
}
--
Naveen K N