• Rohit sfdc
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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