function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TilluTillu 

Unable to update object records through trigger? need help?

I have 2 objects LA_Summery , LA_Detail. while creating LA_Detail record it will need to check with LA_Summery records wheather SE2_Id,Appointment sate is equal or not. If eqaul then we have to update LA_Summery record. If not need to create a new LA_Summery record. I have writtened a trigger but getting exception.


trigger LAdetail on L_A_Detail__c (before insert,before update) {

set<string> Tset = new set<string>();

Map<string,string> LDetailMap1 = new Map<string,string>();
Map<string,string> LSumeryMap2 = new Map<string,string>();

for(L_A_Detail__c La : Trigger.new){
Tset.add(La.SE2_ID__c);
LDetailMap1.put(La.SE2_ID__c+La.Appointment_State__c,La.SE2_ID__c+La.Appointment_State__c);
}

List<L_A_Summary__c> LAlist = [select id,SE2_ID__c,Appointment_State__c from L_A_Summary__c  where SE2_ID__c in:Tset];

for(L_A_Summary__c Al : LAlist){
LSumeryMap2.put(Al.SE2_ID__c+Al.Appointment_State__c,Al.SE2_ID__c+Al.Appointment_State__c);
}

for(L_A_Detail__c D : Trigger.new){
for(L_A_Summary__c S : LAlist){
string s1 = LDetailMap1.get(D.SE2_ID__c+D.Appointment_State__c);
string s2 = LSumeryMap2.get(S.SE2_ID__c+S.Appointment_State__c);

if(s1==s2){
if(D.Appointment_State__c == 'NC'){
S.Variable__c = true;
S.Life__c = true;
S.DI__c = true;
S.Annuity__c = true;
}
if(D.Appointment_State__c == 'NJ'){
S.Variable__c = true;
}
if(D.Appointment_State__c == 'TX'){
S.Variable__c = true;
S.Life__c = true;
S.DI__c = true;
S.Annuity__c = true;
}
if(D.Appointment_State__c == 'VA'){
S.Variable__c = true;
S.Life__c = true;
S.DI__c = true;
S.Annuity__c = true;
}
update LAlist;
}
if(s1!=s2){
L_A_Summary__c Lanew = new L_A_Summary__c();
Lanew.Name = 'SampleTest';
Lanew.License_Number__c = '1234589';
Lanew.Life__c = true;
Lanew.Property__c = true;

if(Lanew.name != Null){
insert Lanew;
}
}
}
}
}
SonamSonam (Salesforce Developers) 
What is the exception that you are getting? can you please copy paste the whole error here?
TilluTillu
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger LAdetail caused an unexpected exception, contact your administrator: LAdetail: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Summery_Trigger: 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.Summery_Trigger: line 12, column 1: []: Trigger.LAdetail: line 56, column 1
SonamSonam (Salesforce Developers) 
Is there another trigger in your ORG on th same object by the name Summery_Trigger?
Please check if it has a SOQL which is returning more records that can be processed by the system.

Non-selective query against large object type (more than 100000 rows) error is seen when the query is not selective enough to return 10% of the total number of rows in your object(i  this case - it seems to be L_A_Detail__c object)