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
harshita gupta 33harshita gupta 33 

Collection size 4,554 exceeds maximum size of 1,000.

this is my apex code:
public class test1CLASS {
    
    public List<SelectOption> CustomerList {get;set;}
    public List<SelectOption> MasterMaterialList {get;set;}
    public List<SelectOption> RetailerList {get;set;}
    public List<SelectOption> influencerList {get;set;}
    public List<SelectOption> shipList {get;set;}
    public List<SelectOption> plantList {get;set;}
    
     public boolean dispSectBool{get;set;}
    public Sale_Order__c saleobj;
     public string pcode;
    public string mcode;
    public string cuscode;
    public string unload;
    public string iduser;
    public List<string> ratevf;
     public ApexPages.StandardController ctrl;
    
    public test1CLASS(ApexPages.StandardController controller)
    { 
        saleobj=(Sale_Order__c)controller.getRecord();
        dispSectBool = false;
     
        CustomerList = new List<SelectOption>();
        MasterMaterialList = new List<SelectOption>();
        RetailerList = new List<SelectOption>();
        influencerList = new List<SelectOption>();
        shipList = new List<SelectOption>();
        plantList = new List<SelectOption>();
        
         CustomerList.add(new SelectOption('','--None--'));
        MasterMaterialList.add(new SelectOption('','--None--'));
        RetailerList.add(new SelectOption('','--None--'));
        influencerList.add(new SelectOption('','--None--'));
        shipList.add(new SelectOption('','--None--'));
        plantList.add(new SelectOption('','--None--'));
        
       Iduser=userinfo.getUserId();
        List<Account> CustomerData = [Select Id,Name from Account];
         
         for(Account cl: CustomerData){
         
            CustomerList.add(new SelectOption(cl.Id,cl.Name));
       }
        
        List<Account> RetailerData = [Select Id,Name,AccountType__c from Account where AccountType__c='Retailer'];
         for(Account cl: RetailerData){
            RetailerList.add(new SelectOption(cl.Id,cl.Name));
        }
        
        List<contact> influencerData = [Select Id,Name,Type__c from contact where Type__c='Influencer'];
         for(contact cl: influencerData){
            influencerList.add(new SelectOption(cl.Id,cl.Name));
        }
        
        List<Ship_to_Party__c> shipData = [Select Id,Name__c from Ship_to_Party__c];
         for(Ship_to_Party__c cl: shipData){
            shipList.add(new SelectOption(cl.Id,cl.Name__c));
        }
        
        List<plants__c> plantData = [Select Id,Name from plants__c];
         for(plants__c cl: plantData){
            plantList.add(new SelectOption(cl.Id,cl.Name));
        }
        if(saleobj.Id != null){
                getMaster();
            }
    }
public void getbag()
{
    saleobj.Quantity_in_MT__c=(saleobj.Quantity_in_Bag__c)/20;
}
    public void getMaster(){
        MasterMaterialList.clear();
        MasterMaterialList.add(new SelectOption('','--None--'));
        Account acc=[Select id,Customer_material_code__c from Account Where id=:saleobj.Customer__c Limit 1];
        if(acc.Customer_material_code__c!=null){
            //List<Customer_Group_Material__c > master=[select id,name,Material_Name__c from Customer_Group_Material__c where Name=:acc.customer_material_code__c];
           List<Customer_Group_Material__c> master=[select id,name,MaterialName__c from Customer_Group_Material__c where Name=:acc.Customer_material_code__c];
            for(Customer_Group_Material__c pl: master){
                system.debug('123');
                system.debug(pl.id);
             MasterMaterialList.add(new SelectOption(pl.Id,pl.MaterialName__c));
            //MasterMaterialList.add(new SelectOption(pl.Id,pl.Name));
            //List<MasterDatabase__c > master=[select id,name,Material_Group__c from MasterDatabase__c where Material_Group__c=:acc.customer_material_code__c AND RecordTypeId='0121m0000006olYAAQ'];
            // for(MasterDatabase__c pl: master){
            // MasterMaterialList.add(new SelectOption(pl.Id,pl.Name));
        }
        }
    }
    
public void getcredit()
{
    cuscode=saleobj.Customer__c;
    system.debug(cuscode);
    
}
public void getvalue()
{
   pcode=saleobj.Plant_Code1__c;//plantcode
   mcode=saleobj.accountcustomer_code__c;//materialcode
    if(saleobj.Customer__c!=null && saleobj.Ship_To_Party1__c==null && saleobj.Transportation_Zone__c==null )
    {
        string custmcode=saleobj.Customer__c;
        unload =[Select id,Name, UnloadingPointId__r.Name FROM Account where id=:custmcode limit 1].UnloadingPointId__r.Name;
        //unload =[Select id,Name, UnloadingPointId__c FROM Account where id=:custmcode limit 1].UnloadingPointId__c;
       saleobj.Unloading_Point_Receiving_Point__c= unload;
        
    }    
    else if(saleobj.Customer__c!=null && saleobj.Ship_To_Party1__c!=null && saleobj.Transportation_Zone__c==null)
    {
        
         system.debug(saleobj.Ship_To_Party1__c);
            string salecode=saleobj.Ship_To_Party1__c;
            unload =[Select id,Unloading_point__c FROM Ship_To_Party__c where id=:salecode limit 1].Unloading_point__c;
       saleobj.Unloading_Point_Receiving_Point__c=unload;
        
        }
        else if(saleobj.Customer__c!=null && saleobj.Ship_To_Party1__c==null && saleobj.Transportation_Zone__c!=null)
        {
            unload =[Select id,Name FROM MasterDatabase__c where id=:saleobj.Transportation_Zone__c limit 1].Name;
            saleobj.vfpageONE_TIME_unloading_point__c=unload;
            saleobj.Unloading_Point_Receiving_Point__c=unload;
           
        }
   ratevf=RATECGP1SAP.call('a141m0000004TXbAAM');
    String FRate1=ratevf.get(0);
    String Rate1=ratevf.get(1);
    String gp1=ratevf.get(2);
    String gp2=ratevf.get(3);
    system.debug('test'+FRate1);
     system.debug('test'+Rate1);
    system.debug('testgp1'+gp1);
     
    saleobj.Freight_Amount__c=decimal.valueOf(FRate1);
    saleobj.Rate__c=decimal.valueOf(Rate1);
    saleobj.Group_1__c=gp1;
    saleobj.Group_2__c=gp2;
     system.debug(''+pcode);//plantcode
    system.debug(mcode);//materialcode
    system.debug(unload);//unloading point
   
}
  
    
    public pagereference dispSect()
    {
        dispSectBool = true;
        system.debug('asdfasdfasdf');
        return null;
    }
    
     public PageReference save() {
        try {
            insert(saleobj);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        //  After successful Save, navigate to the default view page
          PageReference pageRef = new PageReference('');

   pageRef.setRedirect(true);

   return pageRef;

        
    }
     public PageReference cancel() {
                 
        //  After unsuccessful , navigate to the record view page
          PageReference pageRef = new PageReference('');

   pageRef.setRedirect(true);

   return pageRef;

        
    }
}
regards
harshita 
 
ShirishaShirisha (Salesforce Developers) 
Harshitha,

Greetings!

Can you please check the below document for the workaround to avoid getting the exceeded error:

http://kuldeeptyagi.blogspot.com/2011/05/salesforce-work-around-to-overcome-1000.html

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri