I am facing the error in trigger code:
Code in that place:
public void duplicateBusiness() {
set<id> bId = new set<id>();
Map<id,string> duplicateCheck = new Map<id,string>();
Map<string,BusinessDetail__c> DupMap = new Map<string,BusinessDetail__c> ();
for (BusinessDetail__c b : newList)
{
bId.add(b.id);
duplicateCheck.put(b.id,b.DuplicateBusinessCheck__c);
}
List<BusinessDetail__c > StaActiList = new List<BusinessDetail__c >();
StaActiList = [Select Name,DuplicateBusinessCheck__c, BusinessUnit__c,BusinessAlias__c from BusinessDetail__c where DuplicateBusinessCheck__c IN: duplicateCheck.values()];
for(BusinessDetail__c b : StaActiList)
{
DupMap.put(b.DuplicateBusinessCheck__c,b);
} if(!StaActiList.isEmpty())
{
for (BusinessDetail__c b : newList)
{
if(DupMap.containsKey(b.DuplicateBusinessCheck__c))
{
if(b.id != DupMap.get(b.DuplicateBusinessCheck__c).id)
{
b.addError('This account already has a business detail associated to it for this business. Duplicate business details are not allowed.');
}
}
}
}
}
Error Query:
StaActiList = [Select Name,DuplicateBusinessCheck__c, BusinessUnit__c,BusinessAlias__c from BusinessDetail__c where DuplicateBusinessCheck__c IN: duplicateCheck.values()];
Error Message:
Non-selective query against large object type (more than 200000 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 (fo
could u please anyone help me how to rectify this error.