#apex #lwc
#верхушка #lwc
Вопрос:
Я получаю что-то очень странное, когда пытаюсь запустить свой LWC в производство, я получаю систему.Исключение LimitException: Слишком много запросов SOQL: 101
Что странно, так это то, что я уже загрузил его и хотел внести некоторые изменения, изменив один из запросов, и я начал получать систему.Исключение LimitException: Слишком много запросов SOQL: 101
Затем я попытался повторно загрузить свой старый скрипт (который уже был перенесен) и снова систему.Исключение LimitException: Слишком много запросов SOQL: 101
Мой код построен так, что я получаю все необходимые мне запросы в начале, а затем я манипулирую данными, я создал только 5 запросов SOQL, поэтому я не понимаю, почему ограничение в 101 запрос, может быть, я чего-то не понимаю …
Вот мой код:
public class marketDashboard { public marketDashboard(){ } @AuraEnabled(cacheable=true) public static Maplt;String, Listlt;wrapperClassgt;gt; getWrapperClassList(string selectedRegion, date begDate, date endDate){ //Getting the relevant data Listlt;Country__cgt; RelevantCountryList = [select id, name, Region__r.Name, CreatedDate from Country__c where Id in (select country_link__c from Market__c where Focus_Year__c = True)]; Listlt;Market__cgt; RelevantMarketData = [select Id, country_link__c, focus_year__c,status__c, Name, CreatedDate from Market__c where country_link__r.Id IN :RelevantCountryList and Focus_Year__c = True ] ; Listlt;Market__Historygt; MarketHistory = [SELECT id, ParentId, OldValue, NewValue, Field, CreatedById, CreatedDate FROM Market__History where ParentId IN :RelevantMarketData]; Listlt;Leadgt;RelevantPropertyData = [select Id, Name, Market__r.country_link__r.Id, LeadSource, Status, CreatedDate from Lead where Market__r.Id IN :RelevantMarketData]; Listlt;LeadHistorygt; PropHistory = [Select Id, CreatedById, CreatedDate, DataType, LeadId, Field, IsDeleted, NewValue, OldValue From LeadHistory where LeadId IN :RelevantPropertyData]; Listlt;Opportunitygt; RelevantOpportunityData = [Select Id, StageName, main_related_property__r.Market__r.country_link__r.Id, CreatedDate, Name from Opportunity Where RecordType.Id = '0123z000000fOrBAAU' and main_related_property__r.Id IN :RelevantPropertyData]; Listlt;OpportunityHistorygt; OppHistory = [Select Amount, CloseDate, CreatedById, CreatedDate, ExpectedRevenue, ForecastCategory, Id, OpportunityId, PrevAmount, PrevCloseDate, Probability, StageName From OpportunityHistory where OpportunityId IN :RelevantOpportunityData]; //Creating the List to push Listlt;Country__cgt; beitOren = [select id, name from Country__c Limit 50]; system.debug('beitOren: ' beitOren); Maplt;String, Listlt;wrapperClassgt;gt; MaptoPush = new Maplt;String, Listlt;wrapperClassgt;gt;(); Listlt;wrapperClassgt; wrapperList = new Listlt;wrapperClassgt;(); Listlt;wrapperClassgt; wrapperList2 = new Listlt;wrapperClassgt;(); Listlt;wrapperClassgt; wrapperList3 = new Listlt;wrapperClassgt;(); system.debug('RelevantMarketData ' RelevantMarketData); system.debug('RelevantPropertyData ' RelevantPropertyData); system.debug('RelevantOpportunityData ' RelevantOpportunityData); //Data for table1 for(Country__c CountryItem:RelevantCountryList){ if(selectedRegion == 'All'|| selectedRegion == CountryItem.Region__r.id){ wrapperClass wc = new wrapperClass(); // get CountryName wc.CountryName = CountryItem.name; // get RegionName wc.RegionName = CountryItem.Region__r.Name; // get NumberOfMarket Listlt;Market__cgt; MarketOfCurrentCountry = new Listlt;Market__cgt;(); Listlt;Market__cgt; QualifiedMarketList = new Listlt;Market__cgt;(); Listlt;Market__cgt; NotQualifiedMarketList = new Listlt;Market__cgt;(); for(Market__c marketItem: RelevantMarketData ){ if(marketItem.country_link__c == CountryItem.Id){ if(marketItem.status__c == 'Requested' || marketItem.status__c == 'Scrapping' || marketItem.status__c == 'Qualify' || marketItem.status__c == 'Qualifying'){ NotQualifiedMarketList.add(marketItem); } else if(marketItem.status__c != null){ QualifiedMarketList.add(marketItem); } MarketOfCurrentCountry.add(marketItem); } wc.MarketsQualified = QualifiedMarketList.size(); wc.MarketsNotQualified = NotQualifiedMarketList.size(); wc.MarketSupply = MarketOfCurrentCountry.size(); } Listlt;Leadgt; PropertiesInMarket = new Listlt;Leadgt;(); Listlt;Leadgt; TotalQualifiedPropertiesInMarket = new Listlt;Leadgt;(); Listlt;Leadgt; QualifiedNotContactedPropertiesInMarket = new Listlt;Leadgt;(); Listlt;Leadgt; ContactedPropertiesInMarket = new Listlt;Leadgt;(); Listlt;Leadgt; ContactedNotWillingPropertiesInMarket = new Listlt;Leadgt;(); Listlt;Leadgt; ContactedWillingPropertiesInMarket = new Listlt;Leadgt;(); Listlt;Leadgt; DASContactedWillingPropertiesInMarket = new Listlt;Leadgt;(); for(Lead leadItem: RelevantPropertyData){ if(leadItem.Market__r.country_link__c == CountryItem.Id){ PropertiesInMarket.add(leadItem); } if(leadItem.Market__r.country_link__c == CountryItem.Id amp;amp; (leadItem.Status == 'Qualified, Not Contacted' || leadItem.Status == 'Contact initiated' || leadItem.Status == 'Qualified, Not Willing To Trade' || leadItem.Status == 'Qualified, Willing To Trade')){ TotalQualifiedPropertiesInMarket.add(leadItem); } if(leadItem.Market__r.country_link__c == CountryItem.Id amp;amp; (leadItem.Status == 'Qualified, Not Contacted' )){ QualifiedNotContactedPropertiesInMarket.add(leadItem); } if(leadItem.Market__r.country_link__c == CountryItem.Id amp;amp; (leadItem.Status == 'Qualified, not responded' )){ ContactedPropertiesInMarket.add(leadItem); } if(leadItem.Market__r.country_link__c == CountryItem.Id amp;amp; (leadItem.Status == 'Qualified, Not Willing To Trade' )){ ContactedNotWillingPropertiesInMarket.add(leadItem); } if(leadItem.Market__r.country_link__c == CountryItem.Id amp;amp; (leadItem.Status == 'Qualified, Willing To Trade')){ ContactedWillingPropertiesInMarket.add(leadItem); } if(leadItem.Market__r.country_link__c == CountryItem.Id amp;amp; (leadItem.Status == 'Qualified, Willing To Trade' amp;amp; leadItem.LeadSource != 'DAS')){ DASContactedWillingPropertiesInMarket.add(leadItem); } } Listlt;Opportunitygt; OpportunityInMarket = new Listlt;Opportunitygt;(); Listlt;Opportunitygt; EarlyStageOppInMarket = new Listlt;Opportunitygt;(); Listlt;Opportunitygt; AdvancedNegoOppInMarket = new Listlt;Opportunitygt;(); Listlt;Opportunitygt; ClosingOppInMarket = new Listlt;Opportunitygt;(); Listlt;Opportunitygt; ClosedWonOppInMarket = new Listlt;Opportunitygt;(); Listlt;Opportunitygt; AbandonnedOppInMarket = new Listlt;Opportunitygt;(); for(Opportunity OppItem:RelevantOpportunityData){ if(OppItem.main_related_property__r.Market__r.country_link__r.Id == CountryItem.Id){ OpportunityInMarket.add(OppItem); } if(OppItem.main_related_property__r.Market__r.country_link__r.Id == CountryItem.Id amp;amp; OppItem.StageName == 'Early Stage'){ EarlyStageOppInMarket.add(OppItem); } if(OppItem.main_related_property__r.Market__r.country_link__r.Id == CountryItem.Id amp;amp; OppItem.StageName == 'Advanced Negotiation'){ AdvancedNegoOppInMarket.add(OppItem); } if(OppItem.main_related_property__r.Market__r.country_link__r.Id == CountryItem.Id amp;amp; OppItem.StageName == 'Closing'){ ClosingOppInMarket.add(OppItem); } if(OppItem.main_related_property__r.Market__r.country_link__r.Id == CountryItem.Id amp;amp; OppItem.StageName == 'Closed Won'){ ClosedWonOppInMarket.add(OppItem); } if(OppItem.main_related_property__r.Market__r.country_link__r.Id == CountryItem.Id amp;amp; OppItem.StageName == 'Abandoned'){ AbandonnedOppInMarket.add(OppItem); } } wc.PropertySupplyInMarket = PropertiesInMarket.size(); wc.PropertiesQualifiedInMarket = TotalQualifiedPropertiesInMarket.size(); wc.PropertiesQualifiedNotContactedInMarket = QualifiedNotContactedPropertiesInMarket.size(); wc.PropertiesContactedInMarket = ContactedPropertiesInMarket.size(); wc.PropertiesContactedNotWillingInMarket = ContactedNotWillingPropertiesInMarket.size(); wc.PropertiesContactedWillingInMarket = ContactedWillingPropertiesInMarket.size(); wc.PropertiesDASContactedWillingInMarket = DASContactedWillingPropertiesInMarket.size(); wc.OppSupplyInMarket = OpportunityInMarket.size(); wc.OppEarlyStageInMarket = EarlyStageOppInMarket.size(); wc.OppAdvancedNegoInMarket = AdvancedNegoOppInMarket.size(); wc.OppClosingInMarket = ClosingOppInMarket.size(); wc.OppClosedWonInMarket = ClosedWonOppInMarket.size(); wc.OppAbandonnedInMarket = AbandonnedOppInMarket.size(); wrapperList.add(wc); } } //date for total in table 1 wrapperClass wc2 = new wrapperClass(); wc2.totalMarkets = 0; wc2.totalMarketsQualified = 0; wc2.totalMarketsToQualify = 0; wc2.totalPropertySupply = 0; wc2.totalQualifiedProperty = 0; wc2.totalPropertiesContacted = 0; wc2.totalQualifiedNotContacted = 0; wc2.totalQualifiedNotWillingToTrade = 0; wc2.totalQualifiedWillingToTrade = 0; wc2.totalDASQualifiedWillingToTrade = 0; wc2.totalOpportunities = 0; wc2.totalEarlyStageOpportunities = 0; wc2.totalAdvancedOpportunities = 0; wc2.totalClosingOpportunities = 0; wc2.totalClosedWonOpportunities = 0; wc2.totalAbandonedOpportunities = 0; for(wrapperClass ToSumItem: wrapperList){ wc2.totalMarkets = wc2.totalMarkets ToSumItem.MarketSupply; wc2.totalMarketsQualified = wc2.totalMarketsQualified ToSumItem.MarketsQualified; wc2.totalMarketsToQualify = wc2.totalMarketsToQualify ToSumItem.MarketsNotQualified; wc2.totalPropertySupply = wc2.totalPropertySupply ToSumItem.PropertySupplyInMarket; wc2.totalQualifiedProperty = wc2.totalQualifiedProperty ToSumItem.PropertiesQualifiedInMarket; wc2.totalPropertiesContacted = wc2.totalPropertiesContacted ToSumItem.PropertiesContactedInMarket; wc2.totalQualifiedNotContacted = wc2.totalQualifiedNotContacted ToSumItem.PropertiesQualifiedNotContactedInMarket; wc2.totalQualifiedNotWillingToTrade = wc2.totalQualifiedNotWillingToTrade ToSumItem.PropertiesContactedNotWillingInMarket; wc2.totalQualifiedWillingToTrade = wc2.totalQualifiedWillingToTrade ToSumItem.PropertiesContactedWillingInMarket; wc2.totalDASQualifiedWillingToTrade = wc2.totalDASQualifiedWillingToTrade ToSumItem.PropertiesDASContactedWillingInMarket; wc2.totalOpportunities = wc2.totalOpportunities ToSumItem.OppSupplyInMarket; wc2.totalEarlyStageOpportunities = wc2.totalEarlyStageOpportunities ToSumItem.OppSupplyInMarket; wc2.totalAdvancedOpportunities = wc2.totalAdvancedOpportunities ToSumItem.OppAdvancedNegoInMarket; } wrapperList2.add(wc2); ////////////////////////////////////////////////////////////////////////////////////////////////////////// //DAS progress data wrapperClass wc3 = new wrapperClass(); wc3.MarketData = RelevantMarketData; wc3.MarketDataHistory = MarketHistory; wc3.PropData = RelevantPropertyData; wc3.PropDataHistory = PropHistory; wc3.OppData = RelevantOpportunityData; wc3.OppDataHistory = OppHistory; wrapperList3.add(wc3); system.debug(wrapperList3); // Sending data to full map MaptoPush.put('data', wrapperList); MaptoPush.put('total', wrapperList2); MaptoPush.put('DasProgress', wrapperList3); // Returning full Data return MaptoPush; } public class wrapperClass{ @AuraEnabled public string RegionName; @AuraEnabled public string CountryName; @AuraEnabled public Integer MarketSupply; @AuraEnabled public Integer MarketsNotQualified; @AuraEnabled public Integer MarketsQualified; @AuraEnabled public Integer PropertySupplyInMarket; @AuraEnabled public Integer PropertiesQualifiedInMarket; @AuraEnabled public Integer PropertiesQualifiedNotContactedInMarket; @AuraEnabled public Integer PropertiesContactedInMarket; @AuraEnabled public Integer PropertiesContactedNotWillingInMarket; @AuraEnabled public Integer PropertiesContactedWillingInMarket; @AuraEnabled public Integer PropertiesDASContactedWillingInMarket; @AuraEnabled public Integer OppSupplyInMarket; @AuraEnabled public Integer OppEarlyStageInMarket; @AuraEnabled public Integer OppAdvancedNegoInMarket; @AuraEnabled public Integer OppClosingInMarket; @AuraEnabled public Integer OppClosedWonInMarket; @AuraEnabled public Integer OppAbandonnedInMarket; @AuraEnabled public Integer totalMarkets; @AuraEnabled public Integer totalMarketsQualified; @AuraEnabled public Integer totalMarketsToQualify; @AuraEnabled public Integer totalPropertySupply; @AuraEnabled public Integer totalQualifiedProperty; @AuraEnabled public Integer totalPropertiesContacted; @AuraEnabled public Integer totalQualifiedNotContacted; @AuraEnabled public Integer totalQualifiedNotWillingToTrade; @AuraEnabled public Integer totalQualifiedWillingToTrade; @AuraEnabled public Integer totalDASQualifiedWillingToTrade; @AuraEnabled public Integer totalOpportunities; @AuraEnabled public Integer totalEarlyStageOpportunities; @AuraEnabled public Integer totalAdvancedOpportunities; @AuraEnabled public Integer totalClosingOpportunities; @AuraEnabled public Integer totalClosedWonOpportunities; @AuraEnabled public Integer totalAbandonedOpportunities; @AuraEnabled public Listlt;market__cgt; MarketData; @AuraEnabled public Listlt;Market__Historygt; MarketDataHistory; @AuraEnabled public Listlt;Leadgt; PropData; @AuraEnabled public Listlt;LeadHistorygt; PropDataHistory; @AuraEnabled public Listlt;Opportunitygt; OppData; @AuraEnabled public Listlt;OpportunityHistorygt; OppDataHistory; //@AuraEnabled public Integer CreatedMarketBeforeBegDate; //@AuraEnabled public Integer CreatedMarketBeforeEndDate; //@AuraEnabled public Integer MarketCreatedProgress; //@AuraEnabled public Integer QualifiedMarket; //@AuraEnabled public Integer BegQualifiedMarket; //@AuraEnabled public Integer EndQualifiedMarket; //@AuraEnabled public Integer QualifiedMarketProgress; } }
Комментарии:
1. Интересно, не могли бы вы поделиться журналом ошибок, если это возможно. Также, пожалуйста, проверьте, вызываете ли вы какой-либо другой метод из LWC, который может вызвать проблему?