• Neeraja Suribhatla
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hi,
This code has been written by previous developer. I would really appreicate if someone helps me with this error. Thank you.
  : execution of AfterInsert
 
caused by: System.QueryException: 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 (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 AssessmentAnswers on Assessment__c (before insert,before update,after insert) {
    Map<String,List<List<List<String>>>> questionsMap=AssessmentTemplate.getQuestionMap();
    if(Trigger.isInsert && Trigger.isBefore){
        Map<String,Id> rtMap=new Map<String, Id>();
        List<RecordType> rtList=[select id,name from recordtype where name in ('Postsession','Presession','Dass','HolmesRahe')];
        For(RecordType rt:rtList){
            rtMap.put(rt.name,rt.id);
        }
        List<Assessment__c> assList=trigger.new;
        For(Assessment__c ass : assList){
            if(ass.Type__c!=null  && rtMap.containsKey(ass.Type__c.split('::')[1])){
                ass.RecordTypeId=rtMap.get(ass.Type__c.split('::')[1]);
            }
            Integer i=1;
            List<List<List<String>>> assTemplate=questionsMap.get(ass.Type__c);
            if(assTemplate!=null && ass.Answers__c!=null){
                For(String answer : ass.Answers__c.split(',')){
                    if(answer.isNumeric() && i<=assTemplate.size() && Integer.valueof(answer)<assTemplate[i-1][1].size()) { 
                        ass.put('Answer_'+i+'__c',assTemplate[i-1][1][Integer.valueof(answer)]);
                        ass.put('Answer_Value_'+i+'__c',Integer.valueof(answer));
                        ass.put('Question_'+i+'__c',assTemplate[i-1][0][0]);
                    }
                    i++;
                }
            }
        }
    }else if(Trigger.isInsert && Trigger.isAfter){
        AssessmentTemplate.cleanupAssessments();
    }else if(Trigger.isUpdate && Trigger.isBefore){
        List<Assessment__c> assList=trigger.new;
        For(Assessment__c ass : assList){
            Integer i=1;
            List<List<List<String>>> assTemplate=questionsMap.get(ass.Type__c);
            if(assTemplate!=null && ass.Answers__c!=null){
                For(String answer : ass.Answers__c.split(',')){
                    if(answer.isNumeric() && i<=assTemplate.size() && Integer.valueof(answer)<assTemplate[i-1][1].size()) { 
                        ass.put('Answer_'+i+'__c',assTemplate[i-1][1][Integer.valueof(answer)]);
                        ass.put('Answer_Value_'+i+'__c',Integer.valueof(answer));
                        ass.put('Question_'+i+'__c',assTemplate[i-1][0][0]);
                    }
                    i++;
                }
            }
        }
    }
}
Hi,
I need help in writing a test class for the following trigger.  Thank you so much.

trigger childTrigger on child__c (before insert, before update) {
    set<string> OldContactIds = new set<string>();
    map<string,string> mapToParent= new map<string,string>();
    for(child__c childObj : trigger.new){
        if(childObj.CONTACT_OLD_SYSTEM_ID__c !=null){
            OldContactIds.add(childObj.CONTACT_OLD_SYSTEM_ID__c);
            
        }
    }
    if(!OldContactIds.isEmpty()){
        for(Parent__c parentObj :[select id ,OLD_SYSTEM_ID__c from Parent__c where OLD_SYSTEM_ID__c in :OldContactIds]){
            if(parentObj.OLD_SYSTEM_ID__c!=null){
                mapToParent.put(parentObj.OLD_SYSTEM_ID__c,parentObj.id);
                
            }
        }
        for(child__c childObj : trigger.new){
            if(childObj.CONTACT_OLD_SYSTEM_ID__c !=null){
             if(mapToParent.get(childObj.CONTACT_OLD_SYSTEM_ID__c)!=null){
                    childObj.Contact__c = mapToParent.get(childObj.CONTACT_OLD_SYSTEM_ID__c);
                    
                }
            }
        }
    }
    
}
.User-added image
I am getting the above error. I am not sure what is the issue. My Sales Manager dashboard 
User-added image

Can someone help me with this where I am doing wrong? 
Thank you,
Neeraja
How do you set up default app in salesforce lightning?  I would really appreciate if someone helps me.

Thanks,
Neeraja
Hi,
This code has been written by previous developer. I would really appreicate if someone helps me with this error. Thank you.
  : execution of AfterInsert
 
caused by: System.QueryException: 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 (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 AssessmentAnswers on Assessment__c (before insert,before update,after insert) {
    Map<String,List<List<List<String>>>> questionsMap=AssessmentTemplate.getQuestionMap();
    if(Trigger.isInsert && Trigger.isBefore){
        Map<String,Id> rtMap=new Map<String, Id>();
        List<RecordType> rtList=[select id,name from recordtype where name in ('Postsession','Presession','Dass','HolmesRahe')];
        For(RecordType rt:rtList){
            rtMap.put(rt.name,rt.id);
        }
        List<Assessment__c> assList=trigger.new;
        For(Assessment__c ass : assList){
            if(ass.Type__c!=null  && rtMap.containsKey(ass.Type__c.split('::')[1])){
                ass.RecordTypeId=rtMap.get(ass.Type__c.split('::')[1]);
            }
            Integer i=1;
            List<List<List<String>>> assTemplate=questionsMap.get(ass.Type__c);
            if(assTemplate!=null && ass.Answers__c!=null){
                For(String answer : ass.Answers__c.split(',')){
                    if(answer.isNumeric() && i<=assTemplate.size() && Integer.valueof(answer)<assTemplate[i-1][1].size()) { 
                        ass.put('Answer_'+i+'__c',assTemplate[i-1][1][Integer.valueof(answer)]);
                        ass.put('Answer_Value_'+i+'__c',Integer.valueof(answer));
                        ass.put('Question_'+i+'__c',assTemplate[i-1][0][0]);
                    }
                    i++;
                }
            }
        }
    }else if(Trigger.isInsert && Trigger.isAfter){
        AssessmentTemplate.cleanupAssessments();
    }else if(Trigger.isUpdate && Trigger.isBefore){
        List<Assessment__c> assList=trigger.new;
        For(Assessment__c ass : assList){
            Integer i=1;
            List<List<List<String>>> assTemplate=questionsMap.get(ass.Type__c);
            if(assTemplate!=null && ass.Answers__c!=null){
                For(String answer : ass.Answers__c.split(',')){
                    if(answer.isNumeric() && i<=assTemplate.size() && Integer.valueof(answer)<assTemplate[i-1][1].size()) { 
                        ass.put('Answer_'+i+'__c',assTemplate[i-1][1][Integer.valueof(answer)]);
                        ass.put('Answer_Value_'+i+'__c',Integer.valueof(answer));
                        ass.put('Question_'+i+'__c',assTemplate[i-1][0][0]);
                    }
                    i++;
                }
            }
        }
    }
}
Hi,
I need help in writing a test class for the following trigger.  Thank you so much.

trigger childTrigger on child__c (before insert, before update) {
    set<string> OldContactIds = new set<string>();
    map<string,string> mapToParent= new map<string,string>();
    for(child__c childObj : trigger.new){
        if(childObj.CONTACT_OLD_SYSTEM_ID__c !=null){
            OldContactIds.add(childObj.CONTACT_OLD_SYSTEM_ID__c);
            
        }
    }
    if(!OldContactIds.isEmpty()){
        for(Parent__c parentObj :[select id ,OLD_SYSTEM_ID__c from Parent__c where OLD_SYSTEM_ID__c in :OldContactIds]){
            if(parentObj.OLD_SYSTEM_ID__c!=null){
                mapToParent.put(parentObj.OLD_SYSTEM_ID__c,parentObj.id);
                
            }
        }
        for(child__c childObj : trigger.new){
            if(childObj.CONTACT_OLD_SYSTEM_ID__c !=null){
             if(mapToParent.get(childObj.CONTACT_OLD_SYSTEM_ID__c)!=null){
                    childObj.Contact__c = mapToParent.get(childObj.CONTACT_OLD_SYSTEM_ID__c);
                    
                }
            }
        }
    }
    
}
How do you set up default app in salesforce lightning?  I would really appreciate if someone helps me.

Thanks,
Neeraja