Hello Folks,
I have a list which has values from a query. The list has multiple fields, how can I access a specific field from this list?
Problem:
List <Account> listS = [Select
(Select S__c from AS__r
where S__r.Abc__c = 'Confirmed'),
(Select PQR__c from AHS__r)
from Account where Id in: TravellerIds];
List <AS__c> listAS = new list <AS__c>();
for (Account t: listS){
listAS.add(t.AS__r);
}
Problem in pseudocode:
For (every Account in listS)
{
ListAS.add(S__c field from the listS);
}
I have tried what I mentioned in the Problem section but I am unable to access it. Please help me.
Error that I get is this : List has more than 1 row for assignment to SObject.
Thanks a lot for the help.
Note: I do not want to access the S_c field inside the for loop for every AS_c.. I want to access it for every Account.