function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Error in trigger for bulk query



I am putting value of id and stirng in map.





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 t

where t.County_State_Combo__c = : account.get(ids) limit 1];






then again its failing with breaking limit.


Any suggestion one first choice to find distinct market territory based on each account value?




David VPDavid VP

I'm not sure I understand the question, but if you want to create a collection of unique (distinct) elements, use a Set