You need to sign in to do that
Don't have an account?
Noam Damri 3
How to iterate a list inside list in apex
Hey,
So i have this list:
ContactList = [select Id, Name, gender__c , phone, Account.Name, AccountId
(select Id,Name,subject__c,level__c
from custom_object__r)
from Contact];
if im iterating with a for loop on ContactList and reach to the custom_object__r fields, how will i do that?
ive tried this which is not working:
for(Contact TempCon : ContactList)
TempCon.custom_object__r.Name = 'somthing';
ive tried to iterate the opposite way but it's not working as well:
for(custom_object__r Temp : ContactList.custom_object__r)
Temp.Contact.Name = 'somthing';
Help will be appreciated
Thx!
So i have this list:
ContactList = [select Id, Name, gender__c , phone, Account.Name, AccountId
(select Id,Name,subject__c,level__c
from custom_object__r)
from Contact];
if im iterating with a for loop on ContactList and reach to the custom_object__r fields, how will i do that?
ive tried this which is not working:
for(Contact TempCon : ContactList)
TempCon.custom_object__r.Name = 'somthing';
ive tried to iterate the opposite way but it's not working as well:
for(custom_object__r Temp : ContactList.custom_object__r)
Temp.Contact.Name = 'somthing';
Help will be appreciated
Thx!
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
All Answers
https://developer.salesforce.com/forums/ForumsMain?id=906F000000090bvIAA
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
it is working. and i also realized i can do this : Con.custom_object__r[0].Name = 'somthing'; (as i know i have only one custom_object__r for each contact)
Ramu_SFDC - thank as well