You need to sign in to do that
Don't have an account?
Bob
Quote trigger more than 100000 rows
I have a trigger that should only update quotes if the opportunity record type is 'NA Opportunity Record Type' . The trigger must update the Primary_Quote__c checkbox of the newest created record and uncheck any previous records. I added a Opportunity list but i receive the following error below. Any help would be appreciated.
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Trigger_MarkPrimaryQuote caused an unexpected exception, contact your administrator: Trigger_MarkPrimaryQuote: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.Trigger_MarkPrimaryQuote: line 9, column 1
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Trigger_MarkPrimaryQuote caused an unexpected exception, contact your administrator: Trigger_MarkPrimaryQuote: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.Trigger_MarkPrimaryQuote: line 9, column 1
trigger Trigger_MarkPrimaryQuote on Quote (before insert) { List<Opportunity> opps = new List<Opportunity>(); for(Opportunity oppsrec :[Select id, RecordType.Name from Opportunity where RecordType.Name = 'NA Opportunity Record Type' ]){ // List<String> oracleQuoteList = new List<String>(); for(Quote qRec : Trigger.new) { qRec.Primary_Quote__c = true; } // List<Quote> quoteListToUpdate = new List<Quote>(); for(Quote qRec : [SELECT id,Primary_Quote__c,OpportunityId from Quote WHERE Oracle_Quote__c IN : oracleQuoteList]) { qRec.Primary_Quote__c =false; quoteListToUpdate.add(qRec); } // if(quoteListToUpdate != null && quoteListToUpdate .size() > 0) { update quoteListToUpdate; } } }