Hi all, I have a question and a followup question.
I have a query that potentially pulls multiple records:
//Line 25, 26, and 27
List<Territory__c> terrList = [SELECT Name, OwnerId FROM Territory__c WHERE Name IN :allZips];
system.debug('terrList = '+terrList)
After gathing the list, I run a loop to assign the Name and OwnerId to a a Map
It appears that the the code will use the first record in query and assign to the Map. Is this True?// Lines 36,37,38,39,40
system.debug('terrList.size()' +terrList.size());
for(Territory__c t : terrList){
system.debug('for(Territory__c t : terrList) runs');
ziptoId.put(t.Name, t.OwnerId);}
system.debug ('ziptoId.size() = '+ziptoId.size());
If this is true, is there a way to assign a random value (of the queried values) to the map instead of first?
1 risposta
Oops- screenshot of the debug log when I enter in a value that triggers more than one record in the query: