You need to sign in to do that
Don't have an account?

Field Refrence
how to reference contact field from Account object in apex class??
Any Help
Thanks in advance
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
how to reference contact field from Account object in apex class??
Any Help
Thanks in advance
Here is the solution:
Apex Class:
public class Contactreference {
public static void Contactreference(){
List<Account> accountlist = new List<account>();
accountlist= [select id,Name, (select ID,LastName from contacts) from account];
for (Account acc:accountlist){
for(Contact con :acc.contacts){
system.debug(con.LastName);
}
}
}
}
Thanks
All Answers
Here is the solution:
Apex Class:
public class Contactreference {
public static void Contactreference(){
List<Account> accountlist = new List<account>();
accountlist= [select id,Name, (select ID,LastName from contacts) from account];
for (Account acc:accountlist){
for(Contact con :acc.contacts){
system.debug(con.LastName);
}
}
}
}
Thanks