+ Start a Discussion
sudhakar reddy 13sudhakar reddy 13 

maximum 2 semi join sub-selects are allowed how to overcome this error

SELECT quote.Email, quote.TotalPrice, quote.pes__ReadyState__c, quote.pes__Exceptions__c, quote.QuoteNumber, quote.pes__IsPrimary__c, quote.pes__PartnerContactEmail__c, quote.CreatedDate, quote.GrandTotal, quote.pes__PaymentTerms__c, quote.BillingState, quote.ShippingState, quote.ShippingPostalCode, quote.ShippingCity, quote.pes__QuoteType__c, quote.Status, quote.Phone, quote.Discount, quote.Name, quote.BillingCity, quote.BillingCountry, quote.pes__Currency__c, quote.pes__RevisionNumber__c, quote.ShippingCountry, quote.id, quote.BillingStreet, quote.ExpirationDate, quote.pes__PartnerContactPhone__c, quote.BillingPostalCode, quote.ShippingStreet, pes__QuotePriceList__r.pes__PriceList_Currency__c, pes__QuotePriceList__r.pes__Exceptions__c, pes__QuotePriceList__r.createddate, pes__QuotePriceList__r.id, pes__QuotePriceList__r.pes__begindate__c, pes__QuotePriceList__r.pes__enddate__c, pes__QuotePriceList__r.IsActive, pes__QuotePriceList__r.Name, pes__QuotePriceList__r.pes__PriceList_Currency__r.pes__currencyprecision__c, pes__QuotePriceList__r.pes__PriceList_Currency__r.pes__isocurrencycode__c, pes__QuotePriceList__r.pes__PriceList_Currency__r.id, pes__QuotePriceList__r.pes__PriceList_Currency__r.pes__exchangerate__c, pes__QuoteOpportunity__r.pes__OpportunityEndUserPerson__c, pes__QuoteOpportunity__r.pes__OpportunityPriceList__c, pes__QuoteOpportunity__r.ExpectedRevenue, pes__QuoteOpportunity__r.pes__StateCode__c, pes__QuoteOpportunity__r.pes__OpportunityEndUserCompany__c, pes__QuoteOpportunity__r.pes__OpportunityOwner__c, pes__QuoteOpportunity__r.id, pes__QuoteOpportunity__r.CloseDate, pes__QuoteOpportunity__r.Probability, pes__QuoteOpportunity__r.pes__Rating__c, pes__QuoteOpportunity__r.Name, pes__QuoteOpportunity__r.pes__OpportunityCurrency__c, pes__EndUserCompany__r.ShippingState, pes__EndUserCompany__r.accountnumber, pes__EndUserCompany__r.ShippingPostalCode, pes__EndUserCompany__r.name, pes__EndUserCompany__r.ShippingStreet, pes__EndUserCompany__r.BillingCity, pes__EndUserCompany__r.ShippingCountry, pes__EndUserCompany__r.BillingStreet, pes__EndUserCompany__r.ShippingCity, pes__EndUserCompany__r.BillingPostalCode, pes__EndUserCompany__r.pes__ContactCompany__c, pes__EndUserCompany__r.type, pes__EndUserCompany__r.id, pes__EndUserCompany__r.BillingCountry, pes__EndUserCompany__r.BillingState, pes__endusercontact__r.pes__ContactCompany__c, pes__endusercontact__r.MailingPostalCode, pes__endusercontact__r.email, pes__endusercontact__r.MailingCountry, pes__endusercontact__r.Name, pes__endusercontact__r.MailingState, pes__endusercontact__r.id, pes__endusercontact__r.phone, pes__endusercontact__r.MailingCity, pes__endusercontact__r.MailingStreet, pes__quoter__r.pes__userrole__c, pes__quoter__r.pes__lastname__c, pes__quoter__r.pes__linkeduser__c, pes__quoter__r.id, pes__quoter__r.pes__telephone__c, pes__quoter__r.pes__firstname__c, pes__quoter__r.name, pes__quoter__r.pes__emailaddress__c FROM quote WHERE ( (pes__quoter__r.id = 'a001a0000022Q3y' Or (quote.id IN (SELECT pes__ApprovalQuote__c FROM pes__Approval__c WHERE pes__IsCurrentStep__c = true) And (quote.id IN (SELECT pes__ApprovalQuote__c FROM pes__Approval__c WHERE pes__ApprovalAppUser__r.id = 'a001a0000022Q3y') Or quote.id IN (SELECT pes__ApprovalQuote__c FROM pes__Approval__c WHERE pes_approverrole = 0))))) ORDER BY Name DESC, pes__RevisionNumber__c DESC
SELECT quote.Email, quote.TotalPrice, quote.pes__ReadyState__c, quote.pes__Exceptions__c, quote.QuoteNumber, quote.pes__IsPrimary__c, quote.pes__PartnerContactEmail__c, quote.CreatedDate, quote.GrandTotal, quote.pes__PaymentTerms__c, quote.BillingState, quote.ShippingState, quote.ShippingPostalCode, quote.ShippingCity, quote.pes__QuoteType__c, quote.Status, quote.Phone, quote.Discount, quote.Name, quote.BillingCity, quote.BillingCountry, quote.pes__Currency__c, quote.pes__RevisionNumber__c, quote.ShippingCountry, quote.id, quote.BillingStreet, quote.ExpirationDate, quote.pes__PartnerContactPhone__c, quote.BillingPostalCode, quote.ShippingStreet, pes__QuotePriceList__r.pes__PriceList_Currency__c, pes__QuotePriceList__r.pes__Exceptions__c, pes__QuotePriceList__r.createddate, pes__QuotePriceList__r.id, pes__QuotePriceList__r.pes__begindate__c, pes__QuotePriceList__r.pes__enddate__c, pes__QuotePriceList__r.IsActive, pes__QuotePriceList__r.Name, pes__QuotePriceList__r.pes__PriceList_Currency__r.pes__currencyprecision__c, pes__QuotePriceList__r.pes__PriceList_Currency__r.pes__isocurrencycode__c, pes__QuotePriceList__r.pes__PriceList_Currency__r.id, pes__QuotePriceList__r.pes__PriceList_Currency__r.pes__exchangerate__c, pes__QuoteOpportunity__r.pes__OpportunityEndUserPerson__c, pes__QuoteOpportunity__r.pes__OpportunityPriceList__c, pes__QuoteOpportunity__r.ExpectedRevenue, pes__QuoteOpportunity__r.pes__StateCode__c, pes__QuoteOpportunity__r.pes__OpportunityEndUserCompany__c, pes__QuoteOpportunity__r.pes__OpportunityOwner__c, pes__QuoteOpportunity__r.id, pes__QuoteOpportunity__r.CloseDate, pes__QuoteOpportunity__r.Probability, pes__QuoteOpportunity__r.pes__Rating__c, pes__QuoteOpportunity__r.Name, pes__QuoteOpportunity__r.pes__OpportunityCurrency__c, pes__EndUserCompany__r.ShippingState, pes__EndUserCompany__r.accountnumber, pes__EndUserCompany__r.ShippingPostalCode, pes__EndUserCompany__r.name, pes__EndUserCompany__r.ShippingStreet, pes__EndUserCompany__r.BillingCity, pes__EndUserCompany__r.ShippingCountry, pes__EndUserCompany__r.BillingStreet, pes__EndUserCompany__r.ShippingCity, pes__EndUserCompany__r.BillingPostalCode, pes__EndUserCompany__r.pes__ContactCompany__c, pes__EndUserCompany__r.type, pes__EndUserCompany__r.id, pes__EndUserCompany__r.BillingCountry, pes__EndUserCompany__r.BillingState, pes__endusercontact__r.pes__ContactCompany__c, pes__endusercontact__r.MailingPostalCode, pes__endusercontact__r.email, pes__endusercontact__r.MailingCountry, pes__endusercontact__r.Name, pes__endusercontact__r.MailingState, pes__endusercontact__r.id, pes__endusercontact__r.phone, pes__endusercontact__r.MailingCity, pes__endusercontact__r.MailingStreet, pes__quoter__r.pes__userrole__c, pes__quoter__r.pes__lastname__c, pes__quoter__r.pes__linkeduser__c, pes__quoter__r.id, pes__quoter__r.pes__telephone__c, pes__quoter__r.pes__firstname__c, pes__quoter__r.name, pes__quoter__r.pes__emailaddress__c FROM quote WHERE ( (pes__quoter__r.id = 'a001a0000022Q3y' Or (quote.id IN (SELECT pes__ApprovalQuote__c FROM pes__Approval__c WHERE pes__IsCurrentStep__c = true) And (quote.id IN (SELECT pes__ApprovalQuote__c FROM pes__Approval__c WHERE pes__ApprovalAppUser__r.id = 'a001a0000022Q3y') Or quote.id IN (SELECT pes__ApprovalQuote__c FROM pes__Approval__c WHERE pes_approverrole = 0))))) ORDER BY Name DESC, pes__RevisionNumber__c DESC
Andy BoettcherAndy Boettcher
You have hit a platform limit.  You will need to seperate your query into small subqueries and then combine programmatically in your class or trigger.