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
sashamsasham 

issues with the limit when querying (more data from salesforce )

 I have some questions and clarification. This code is used using Vf page and button . when i click on the button it will update the states We have huge participants in the system . i am querying all the participants , states and Reviews in my code. pls let me know it will not throw an error in regards to governor limit if that so , how do i change and what to do for that ( i used map for that ) still confusing Pls answer if it is possible
public PageReference insertstates(

String statesRec = assessed;
String quiz= '123'
PsRecsById = new Map<id, States__c>();
recsById =  new Map<id, (participant__c> ();
         for(States__c st : [select Id,participant__c,state_c
                                         from  States__c
                                           where participant__c!=null and State__c=:statesRec])
             {
                PsRecsById .put(st.participant__c, st);
                 
             }
         stateIds = new Set<ID>();
         stateIds= PsRecsById .keyset();
         
        
         reviewtRecsById.put= new Map<Decimal, Review_C>(); 
         for(Review_C  assrecs : [select Id, RL_C,Quiz_C,CreatedDate from  Review_C where  Quiz_C=:quiz])
             {
                reviewtRecsById.put((Decimal)assrecs.RL_C, assrecs);
                 
             } 
         
          List<States__c> insertList = new List <States__c>();
         
         for(participant__c par :[select id,RL_C from participant__c where RL_C =:reviewtRecsById.keySet()])
             {
               // recsById.put(par.id, par);
                if(!stateIds.contains(par.ID))
                {
                     States__c stateObj = new States__c();
                     stateObj.participant__c = par.Id;
                     stateObj.State__c =statesRec.id;                  
                     stateObj.ReceivedAt_C=reviewRecsById.get(par.RL_C ).CreatedDate;
                     insertList.add(stateObj);
                }
             }
         if(insertList.size()>0)
         {
             insert insertList;
         }
      
return null; 
}