You need to sign in to do that
Don't have an account?
How do I access child records
Hi Friends,
Below given is the code ,I need to access the contacts last name assiciated with the acocunts.I am not able to .Can somebody tell me how to access the contacts asscoaied wih the account.How do I display lastname and name of the contacts asscoaited with the particular account.
trigger Trigger1 on Account (before insert,before update) {
account []a=[SELECT Name,(SELECT LastName,name FROM Contacts)FROM Account];
//account []acc =[Select a.Name, a.Id, (Select AccountId, LastName, FirstName From Contacts) From Account a];
for(Account p:a)
{
System.debug('The values in the list account is ........................'+p.name);
//System.debug('The values in the list account related contact lastname is ........................'+p.lastname);
}
}
Thanks,
trick
It would be something like this. Though I suggest loading only those accounts fired in the trigger, this code is at risk.
All Answers
It would be something like this. Though I suggest loading only those accounts fired in the trigger, this code is at risk.
Thanks a lot ,
Trick
Please mark Abhinav's post as solution if it helped you. So others may get benefit.
Thanks
Ankit Arora
Blog | Facebook | Blog Page