visualforce Extension:
public class Autocompletefields_custom1 {
public Autocompletefields_custom1(customreport controller) {
}
//Variable declaration
transient public String[] jsonDescriptionData;
//Constructor with argument as standrad controller
public AutoCompletefields_custom1(ApexPages.StandardController controller) { }
//Simple construcor
public AutoCompletefields_custom1(){}
//Method to return all nicopin for France user
transient public String[] jsonDescriptionData6;
//Method to return all nicopin for France user
public List<string> getjsonDescriptionData6(){
jsonDescriptionData6 = new List<string>();
//List of nicopin for france
List<Quote_line_item__c> francePinCodeList=[SELECT name from Quote_line_item__c limit 50000];
//Set to get all nico pin as string
Set<String> pncodeSet=new Set<String>();
String quoteStr='"';
//Iterate to collect set of all nico pin
for(Quote_line_item__c cpnCod : francePinCodeList){
if(cpnCod.name!=Null){
if(!cpnCod.name.contains(quoteStr)){
pncodeSet.add(cpnCod.name);
}//End of if
}
}//End of for loop
//Iterate to collect all pin in string format
for(String str:pncodeSet){
jsonDescriptionData6.add('"'+str+'"');
}
//To sort the nicopin list
jsonDescriptionData6.sort();
return jsonDescriptionData6;
//End of method
}
transient public String[] jsonDescriptiondata7;
//Method to return all nicopin for France user
public List<string> getjsonDescriptionData7(){
jsonDescriptionData7 = new List<string>();
//List of nicopin for france
List<Quote_line_item__c> francePinCodeList=[SELECT Client_P_N__c from Quote_line_item__c limit 50000];
//Set to get all nico pin as string
Set<String> pncodeSet=new Set<String>();
String quoteStr='"';
//Iterate to collect set of all nico pin
for(Quote_line_item__c cpnCod : francePinCodeList){
if(cpnCod.Client_P_N__c!=NULL){
if(!cpnCod.Client_P_N__c.contains(quoteStr)){
pncodeSet.add(cpnCod.Client_P_N__c);
}//End of if
}
}//End of for loop
//Iterate to collect all pin in string format
for(String str:pncodeSet){
jsonDescriptionData7.add('"'+str+'"');
}
//To sort the nicopin list
jsonDescriptionData7.sort();
return jsonDescriptionData7;
//End of method
}
transient public String[] jsonDescriptiondata8;
//Method to return all nicopin for France user
public List<string> getjsonDescriptionData8(){
jsonDescriptionData8 = new List<string>();
//List of nicopin for france
List<Quote_line_item__c> francePinCodeList=[SELECT N_EP_DPI__c from Quote_line_item__c limit 50000];
//Set to get all nico pin as string
Set<String> pncodeSet=new Set<String>();
String quoteStr='"';
//Iterate to collect set of all nico pin
for(Quote_line_item__c cpnCod : francePinCodeList){
if(cpnCod.N_EP_DPI__c!=NULL){
if(!cpnCod.N_EP_DPI__c.contains(quoteStr)){
pncodeSet.add(cpnCod.N_EP_DPI__c);
}//End of if
}
}//End of for loop
//Iterate to collect all pin in string format
for(String str:pncodeSet){
jsonDescriptionData8.add('"'+str+'"');
}
//To sort the nicopin list
jsonDescriptionData8.sort();
return jsonDescriptionData8;
//End of method
}
transient public String[] jsonDescriptiondata9;
//Method to return all nicopin for France user
public List<string> getjsonDescriptionData9(){
jsonDescriptionData9 = new List<string>();
//List of nicopin for france
List<Quote__c> francePinCodeList=[SELECT Bill_To_Country__c from Quote__c Limit 50000];
//Set to get all nico pin as string
Set<String> pncodeSet=new Set<String>();
String quoteStr='"';
//Iterate to collect set of all nico pin
for(Quote__c cpnCod : francePinCodeList){
if(cpnCod.Bill_To_Country__c!=NULL){
if(!cpnCod.Bill_To_Country__c.contains(quoteStr)){
pncodeSet.add(cpnCod.Bill_To_Country__c);
}//End of if
}
}//End of for loop
//Iterate to collect all pin in string format
for(String str:pncodeSet){
jsonDescriptionData9.add('"'+str+'"');
}
//To sort the nicopin list
jsonDescriptionData9.sort();
return jsonDescriptionData9;
//End of method
}
transient public String[] jsonDescriptiondata10;
//Method to return all nicopin for France user
public List<string> getjsonDescriptionData10(){
jsonDescriptionData10 = new List<string>();
//List of nicopin for france
List<opportunity> francePinCodeList=[SELECT name from opportunity Limit 50000];
//Set to get all nico pin as string
Set<String> pncodeSet=new Set<String>();
String quoteStr='"';
//Iterate to collect set of all nico pin
for(opportunity cpnCod : francePinCodeList){
if(cpnCod.name!=NULL){
if(!cpnCod.name.contains(quoteStr)){
pncodeSet.add(cpnCod.name);
}//End of if
}
}//End of for loop
//Iterate to collect all pin in string format
for(String str:pncodeSet){
jsonDescriptionData10.add('"'+str+'"');
}
//To sort the nicopin list
jsonDescriptionData10.sort();
return jsonDescriptionData10;
//End of method
}
}
i am getting the error like this how can i able to solve it
Too many query rows: 50001
Attribution to: Teja
Possible Suggestion/Solution #1
The query limit applies to the sum of all queries in one transaction, so the 'limit 50000' doesn't help here.
Alternatively you can check the limits before doing the query:
Integer rowsLeft = Limits.getLimitQueryRows() - Limits.getQueryRows();
francePinCodeList = [SELECT name from Quote_line_item__c limit :rowsLeft];
And maybe check if rowsLeft == 0 to throw an error message
Attribution to: Frederik
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33923