You need to sign in to do that
Don't have an account?

System.QueryException: Non-selective query against large object type
Hi all,
I need to avoid insertion of duplicate Accounts in Managed Package.So i implement the following trigger.Its works in Some clients Orgs,But i got below error in some client orgs.
"
Apex trigger NameSpace__Test_AccountSyn caused an unexpected exception, contact your administrator: NameSpace__Test_AccountSyn: 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 Test_AccountSyn on Account(before insert,before update,after insert , after update , after delete)
{
if((Trigger.isBefore && Trigger.isInsert))
{
List<Account>accList=[select name,phone,website,BillingState,BillingCity,BillingPostalCode from Account where phone!=null ];
for (Account acc: Trigger.New)
{
if(accList.size()>0)
{
for(Account at:accList)
{
if(at.phone==acc.phone&& at.Billingpostalcode==acc.Billingpostalcode && at.website==acc.website && at.BillingCity==acc.BillingCity){
acc.addError(' <font color="blue"> The Account is already exist </br></br>please find below</font></br><a href="/'+at.id+'">'+at.Name+'</a>', FALSE);
}
}
}
}
}
}
Can any one Help us
I need to avoid insertion of duplicate Accounts in Managed Package.So i implement the following trigger.Its works in Some clients Orgs,But i got below error in some client orgs.
"
Apex trigger NameSpace__Test_AccountSyn caused an unexpected exception, contact your administrator: NameSpace__Test_AccountSyn: 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 Test_AccountSyn on Account(before insert,before update,after insert , after update , after delete)
{
if((Trigger.isBefore && Trigger.isInsert))
{
List<Account>accList=[select name,phone,website,BillingState,BillingCity,BillingPostalCode from Account where phone!=null ];
for (Account acc: Trigger.New)
{
if(accList.size()>0)
{
for(Account at:accList)
{
if(at.phone==acc.phone&& at.Billingpostalcode==acc.Billingpostalcode && at.website==acc.website && at.BillingCity==acc.BillingCity){
acc.addError(' <font color="blue"> The Account is already exist </br></br>please find below</font></br><a href="/'+at.id+'">'+at.Name+'</a>', FALSE);
}
}
}
}
}
}
Can any one Help us
{
if((Trigger.isBefore && Trigger.isInsert))
{
List<String> phoneList = new List<String>();
for (Account a : Trigger.new){
phoneList.add(a.phone);
}
List<Account>accList=[select name,phone,website,BillingState,BillingCity,BillingPostalCode from Account where phone IN : phoneList ];
for (Account acc: Trigger.New)
{
if(accList.size()>0)
{
for(Account at:accList)
{
if(at.phone==acc.phone&& at.Billingpostalcode==acc.Billingpostalcode && at.website==acc.website && at.BillingCity==acc.BillingCity){
acc.addError(' <font color="blue"> The Account is already exist </br></br>please find below</font></br><a href="____/'+at.id+'">'+at.Name+'</a>', FALSE);
}
}
}
}
}
}