You need to sign in to do that
Don't have an account?
Error in trigger for bulk query
Hi,
I am putting value of id and stirng in map.
account.put(a.Id,a.Shipping_County__c+a.ShippingState);
List<Territory_Market__c> territoryMarket = [Select t.Territory_State__c, t.Territory_Market__c, t.Territory_County__c,
t.Parent_Market__r.Name, t.Parent_Market__c,t.County_State_Combo__c From Territory_Market__c t
where t.County_State_Combo__c in : account.values()];
Now getting list from territory market on countystate combo can have multiple record.
In account.values() ,each value ahve multiple recrod from market territory object. and there is breaking limit.
I just need one recrod for each value( kind of distinct).
How to solve this issue?
If I write,
List<Territory_Market__c> territoryMarket = new List<Territory_Market__c>();
for(Id ids : account.keySet()){List<
Territory_Market__c> getterritoryMarket =[Select t.Territory_State__c, t.Territory_Market__c, t.Territory_County__c,t.Parent_Market__r.
Name, t.Parent_Market__c,t.County_State_Combo__c From Territory_Market__c twhere t.County_State_Combo__c = : account.get(ids) limit 1];
if(getterritoryMarket.size()>0){territoryMarket.add(getterritoryMarket[0]);
}
}
then again its failing with breaking limit.
Any suggestion one first choice to find distinct market territory based on each account value?
Thanks,
I'm not sure I understand the question, but if you want to create a collection of unique (distinct) elements, use a Set
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_sets.htm