You need to sign in to do that
Don't have an account?
Girish Reddy 52
Hello Can someone help me with this code, I'm getting error since 2hrs unable to solve this. I tried it on developer console Anonymous window the error say that Line: 1, Column: 5 Unexpected token '<'.
List<Account> Aop = [Select Name (Select Name, StageName From Opportunites) From Account];
for(Account acc : Aop){
system.debug('Parent '+ acc.name);
for(Opportunity opp: acc.opportunity){
system.debug('Child '+ opp.Stagename);
}
}
for(Account acc : Aop){
system.debug('Parent '+ acc.name);
for(Opportunity opp: acc.opportunity){
system.debug('Child '+ opp.Stagename);
}
}
Please change your code as per the highlighted line.
List <Account> listOfAccount = [SELECT Name, (SELECT Name, StageName FROM Opportunities) FROM Account];
for(Account acc : listOfAccount){
system.debug('Parent '+ acc.name);
for(Opportunity opp: acc.Opportunities){
system.debug('Child '+ opp.Stagename);
}
}
Regards,
Shatrughna Salunke
All Answers
Please mark as Best Answer if above information was helpful so that it can help others in the future.
Thanks,
Please change your code as per the highlighted line.
List <Account> listOfAccount = [SELECT Name, (SELECT Name, StageName FROM Opportunities) FROM Account];
for(Account acc : listOfAccount){
system.debug('Parent '+ acc.name);
for(Opportunity opp: acc.Opportunities){
system.debug('Child '+ opp.Stagename);
}
}
Regards,
Shatrughna Salunke