You need to sign in to do that
Don't have an account?
MikeCamp
System.QueryException: Non-selective query against large object type with indexed field (Unique and External ID)
I randomly get this error in a trigger and the field(RPRegistrationID__c) on the custom object(RP_Registration__c) that I am querying is indexed(set as Unique and External ID) Any sugestions on what is causing this?
Here is the code
if(!surveyUpdates.isEmpty()){
Map<string,ID> regIDMap = new Map<string,ID>();
for (RP_Registration__c thisReg : [SELECT Id, RPRegistrationID__c from RP_Registration__c
where RPRegistrationID__c in :surveyUpdates]) {
regIDMap.put(thisReg.RPRegistrationID__c,thisReg.ID);
}
//update survey to point registration
for(Survey__c thisSurvey : surveys) {
if(regIDMap.containsKey(thisSurvey.RPRegistrationID__c)){
thisSurvey.Registration__c = regIDMap.get(thisSurvey.RPRegistrationID__c);
}
}
Here is the code
if(!surveyUpdates.isEmpty()){
Map<string,ID> regIDMap = new Map<string,ID>();
for (RP_Registration__c thisReg : [SELECT Id, RPRegistrationID__c from RP_Registration__c
where RPRegistrationID__c in :surveyUpdates]) {
regIDMap.put(thisReg.RPRegistrationID__c,thisReg.ID);
}
//update survey to point registration
for(Survey__c thisSurvey : surveys) {
if(regIDMap.containsKey(thisSurvey.RPRegistrationID__c)){
thisSurvey.Registration__c = regIDMap.get(thisSurvey.RPRegistrationID__c);
}
}
Best Answer chosen by MikeCamp
MikeCamp
I found that some of the Survey__c object records are coming in with a null in the RPRegistrationID__c field (used to populate the surveyUpdates list),