• Jacqueline Kiernan
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
We have hit a limit of 4000 records on our custom visualforce page even with pagination. public class PharmacyWorkListController {     //private members vars for pagination     private integer counter=0;  //keeps track of the offset     private integer list_size=300; //sets the page size or number of rows     public integer total_size=0; //used to show user the total size of the list          // the soql without the order and limit     private String soql {get;set;}          // the soql record count     public Integer size {get;set;}      private String countQuery {get;set;}     private Integer numRecords {get;set;}          private String EQPharmacy {get;set;}     private String PName {get;set;}     private String Client {get;set;}     private String PStage {get;set;}     private String Exceptions {get;set;}     private User user {get;set;}     public List<SelectOption> Clients {get; set;}     public Integer RecordCount{         get {return numRecords == null ? 0 : numRecords;}     }               // the collection of accounts to display     public List<PharmacyDrug__c> PharmacyDrugs {get;set;}               // the current sort direction. defaults to asc     public String sortDir {         get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }         set;     }          // the current field to sort by. defaults to  name     public String sortField {         get  { if (sortField == null) {sortField = 'EarlyRefill__c'; } return sortField;  }         set;     }     public string additionalSort { get; set; }               // init the controller and display some sample data when the page loads     public PharmacyWorkListController() {         //get current user's Account Id         user = [Select Id, AccountId from User where Id = :UserInfo.getUserId()];                  soql = 'Select ID, Name, Run_Copay__c, account__c, active_prescription__c, Active_Prescription__r.Prescription_Number__c, account__r.EQ_Pharmacy__r.Name, account__r.Name, ShipStatus_Image__c, Active_Prescription__r.Pharmacy__c, Active_Prescription__r.Name, Exceptions__c, Claim_Notes__c, EarlyRefill__c, Status__c, Ship__c, Comments__c, RXPlus_RXRequestStatus__c, RXPlus_RXRequestDate__c, RXPlus_RXRequestComment__c, Account__r.EQ_Main_Provider_Work_Site__c, Account__r.EQ_Main_Provider__r.Name  From PharmacyDrug__c where account__c != null ';                    string acronym = '';         Clients = new List<SelectOption>();                  Set<Id> clientIdSet = new Set<Id>();         for(CE_Contract__c ceContract : [SELECT Id, Client__c from CE_Contract__c where (Pharmacy__c = :user.AccountId OR Pharmacy__r.ParentId = :user.AccountId) AND Start_Date__c <= TODAY AND End_Date__c >= TODAY]){             clientIdSet.add(ceContract.Client__c);         }                  AggregateResult[] clientsAr = [Select Health_Center_Acronym__c from Account where Id in :clientIdSet and Active_Client__c = true and RecordType.Name in ('Business Account', 'FQHC', 'Hospital') GROUP BY Health_Center_Acronym__c ];          for(AggregateResult clientAr : clientsAr){             acronym = String.valueOf(clientAr.get('Health_Center_Acronym__c')) ;             if(acronym != null){                 Clients.add(new SelectOption('\'' + acronym + '\'', acronym));             }         }              }          // toggles the sorting of query from asc<-->desc     public void toggleSort() {         sortDir = sortDir.equals('asc') ? 'desc' : 'asc';         runQuery();     }          public void runQuery() {         try {             PharmacyDrugs = Database.query(soql + ' order by ' + sortField + ' ' + sortDir +  additionalSort +' limit ' + list_size + ' offset ' + counter);             numRecords = Database.countQuery(countQuery + ' limit 49200');             total_size = numRecords;             size = PharmacyDrugs.size();                      } catch (Exception e) {             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));         }              }                    // runs the search with parameters passed via Javascript     public PageReference runSearch() {         String whereClause = '';                  //get search parameters from querystring         String NewSearch = Apexpages.currentPage().getParameters().get('NewSearch');         if(NewSearch != null && NewSearch == 'true'){             counter = 0;             PName = Apexpages.currentPage().getParameters().get('Name');             Client = Apexpages.currentPage().getParameters().get('ClientID');             PStage = Apexpages.currentPage().getParameters().get('PStages');             Exceptions = Apexpages.currentPage().getParameters().get('Exceptions__c');         }                                    soql = 'Select ID, Name, Run_Copay__c, account__c, active_prescription__c, Active_Prescription__r.Prescription_Number__c, account__r.EQ_Pharmacy__r.Name, account__r.Name, ShipStatus_Image__c, Active_Prescription__r.Pharmacy__c, Active_Prescription__r.Name, Exceptions__c, Claim_Notes__c, EarlyRefill__c, Status__c, Ship__c, Comments__c, RXPlus_RXRequestStatus__c, RXPlus_RXRequestDate__c, RXPlus_RXRequestComment__c, Account__r.EQ_Main_Provider_Work_Site__c, Account__r.EQ_Main_Provider__r.Name From PharmacyDrug__c';          countQuery = 'select count() from PharmacyDrug__c';         //filter to records where the pharmacy matches the current user's account id         whereClause = ' where account__c != null and (Active_Prescription__r.Pharmacy__c = \'' + user.AccountId + '\' OR Active_Prescription__r.Pharmacy__r.ParentId = \'' + user.AccountId + '\')';         additionalSort = '';                  /*if (EQPharmacy != null && !EQPharmacy.equals(''))             whereClause += '  and account__r.EQ_Pharmacy__r.Name LIKE \''+String.escapeSingleQuotes(EQPharmacy)+'%\'';*/                  if (PName != null && !PName.equals(''))             whereClause += ' and account__r.Name LIKE \''+String.escapeSingleQuotes(PName)+'%\'';                  if (Client != null && !Client.equals(''))             whereClause += ' and account__r.Pt_Health_Ctr_Acn__c IN ('+ Client +')';                  //allow them to filter to Lead and Enrolled pts at the same time         if (PStage != null && !PStage.equals('')){             if(PStage.equals('Lead or Enrolled')){                 whereClause += ' and (account__r.Patient_Account_Stage__c = \'Lead\' OR account__r.Patient_Account_Stage__c = \'Enrolled\')';             }             else{                 whereClause += ' and account__r.Patient_Account_Stage__c = \''+String.escapeSingleQuotes(PStage)+'\'';             }         }          if (Exceptions != null && Exceptions.equals('Copays To Run')){             whereClause += '  AND account__r.Patient_Lead_Stage__c != \'Lost\'  AND account__r.Patient_Account_Stage__c != \'Lost\' AND EarlyRefill__c <= TODAY AND Status__c = \'On Deck\' AND Run_Copay__c=True';             additionalSort = ', account__r.Name ASC ';         }         //Removed 8/6/2018 EQIT-4259 https://na8.salesforce.com/a0QC000000JiSA5         //if (Exceptions != null && Exceptions.equals('OKTS')){         //    whereClause += '  AND Status__c = \'OKTS\' AND Ship__c<=TODAY';         //    additionalSort = ', account__r.Name ASC ';         //}         //Added 8/6/2018 EQIT-4259 https://na8.salesforce.com/a0QC000000JiSA5         if (Exceptions != null && Exceptions.equals('OKTS')){             whereClause += '  AND Status__c = \'OKTS\' AND ((Ship__c<=TODAY and account__r.EQ_Pharmacy__r.Name <> \'DeliverCareRx\') OR (Ship__c<=NEXT_N_DAYS:31 and account__r.EQ_Pharmacy__r.Name = \'DeliverCareRx\'))';             additionalSort = ', account__r.Name ASC ';         }          if (Exceptions != null && Exceptions.equals('Waiting On Prescription')){             whereClause += '  AND Status__c = \'Waiting On Prescription\'';         }         if (Exceptions != null && Exceptions.equals('Waiting On PA')){             whereClause += ' AND Exceptions__c = \'' + Exceptions + '\' AND account__r.Patient_Lead_Stage__c != \'Lost\' AND account__r.Patient_Account_Stage__c != \'Lost\'';         }         if (Exceptions != null && !Exceptions.equals('') && !Exceptions.equals('Copays To Call') && !Exceptions.equals('OKTS') && !Exceptions.equals('Review Pending') && !Exceptions.equals('Copays To Run') && !Exceptions.equals('Post Enrollment Call') && !Exceptions.equals('Waiting On PA') && !Exceptions.equals('Waiting On Prescription'))             whereClause += ' AND  Exceptions__c LIKE \'%'  +  Exceptions +'%\' ';                  if (Exceptions != null && Exceptions.equals('EQ Review')){             whereClause += '  AND Status__c != \'Patient Declined\'';         }         soql += whereClause;         countQuery += whereClause;                  // run the query again         runQuery();                  return null;     }          // use apex describe to build the picklist values     public List<String> PStages {         get {             if (PStages == null) {                                  PStages = new List<String>();                 Schema.DescribeFieldResult field = Account.Patient_Account_Stage__c.getDescribe();                                  for (Schema.PicklistEntry f : field.getPicklistValues())                     PStages.add(f.getLabel());                              }             return PStages;                   }         set;     }               //public PageReference SaveInlineChanges()     public void SaveInlineChanges()     {         update PharmacyDrugs;         runQuery();     }          //*****************************Pagination methods*****************************     public PageReference Beginning() { //user clicked beginning       counter = 0;       runSearch();       return null;    }     public PageReference Previous() { //user clicked previous button       counter -= list_size;       runSearch();       return null;    }     public PageReference Next() { //user clicked next button       counter += list_size;       runSearch();       return null;    }     public PageReference End() { //user clicked end       counter = total_size - math.mod(total_size, list_size) - 1;       runSearch();       return null;    }          public Integer CounterVal{         get{ return counter + 1;}     }     public Integer LastRecord{         get{              if(counter + list_size > total_size) return total_size;             return counter + list_size;          }     }    public Boolean getDisablePrevious() {        //this will disable the previous and beginning buttons       if (counter > 0) return false; else return true;    }     public Boolean getDisableNext() { //this will disable the next and end buttons       if (counter + list_size < total_size) return false; else return true;    }     public Integer getTotal_size() {       return total_size;    }         public Integer getPageNumber() {       return counter/list_size + 1;    }     public Integer getTotalPages() {       if (math.mod(total_size, list_size) > 0) {          return total_size/list_size + 1;       } else {          return (total_size/list_size);       }    }     public Integer pageNumber{         get { return getPageNumber(); }     }     public Integer totalPages{         get { return getTotalPages();}     }          public boolean disableNext{         get{              return getDisableNext();         }     }     public boolean disablePrevious{         get{              return getDisablePrevious();          }     }     //*****************************End Pagination methods***************************** 

We are not sure where to go next. Any help is appreciated. 
I am hitting a limit of 2000 records being loaded in my custom visual force page in our community. We can see that there are well over 2000 records but after we hit the 2000 mark there is no other values loaded as we navigate to the further pages. 
I am hitting a limit of 2000 records being loaded in my custom visual force page in our community. We can see that there are well over 2000 records but after we hit the 2000 mark there is no other values loaded as we navigate to the further pages.