+ Start a Discussion
Pradeep dPradeep d 

hi, please help me to reduce view state limit

public class contactSend {
 public set<Id> lstSelectedCons {get;set;}
 public Date dat {
  set;
  get;
 }
 public Date To {
  set;
  get;
 }
 public Boolean showCalendarField {
  get;
  set;
 }
 public Date calendarFieldVal {
  get;
  set;
 }
 public List < Contact > SelectedDc {
  set;
  get;
 }
 public List < WrapDummy > wdlist {
  set;
  get;
 }
 public List < WrapDummy > wdlist1 {
  set;
  get;
 }
 public List < WrapDummy > wdlist2 {
  set;
  get;
 }

 public transient List < Contact > ct {
  set;
  get;
 }
 public string selectedvalue {
  set;
  get;
 }
 public id DummyconId {
  set;
  get;
 }
 public Map < string, id > mMap {
  set;
  get;
 }
 public string dummymail {
  set;
  get;
 }
 public string result {
  set;
  get;
 }
 public String messageBody;
 public Integer totalSize {
  set;
  get;
 }
 public Integer totalPages {
  set;
  get;
 }
 public Set < String > Scon;
 public set < id > setIds;
 public string selectedDataType {
  set;
  get;
 }
 public List < contact > ContactsToShow {
  get;
  set;
 }
 public Integer counter = 0; //TO track the number of records parsed
 public Integer limitSize = 100; //Number of records to be displayed
 //Integer totalSize =0;

 //pagination Standard set
 /**public Apexpages.Standardsetcontroller con;
    
 public Map<Id,Decimal> quantityMap {set;get;}
 public Set<Id> SelectedPropertyIds {set;get;}
 public string ContextItem {set;get;}
 public string ContextItemValue {set;get;} **/
 public Boolean SelectedAllProperties {
  set;
  get;
 }

 //List to show the limited records on the page
 /**  public List<WrapDummy> ContactsToShow {get;set;}
   public List<wrapDummy> currentrecords {get;set;}
   Integer counter = 0;//TO track the number of records parsed
   Integer limitSize = 10;//Number of records to be displayed
   Integer totalSize {set;get;} //To Store the total number of records available

  **/
 public List < Dummy_Contact__c > dummylist {
  set;
  get;
 }

 Public List < Contact > conlist {
  set;
  get;
 }
 public List < Dummy_Contact__c > dclist {
   set;
   get;
  }
  // filter condition variables
 public List < SelectOption > options {
  get;
  set;
 }
 public List < SelectOption > operatorOptions {
  get;
  set;
 }
 public static string selectedOperatorOption {
  get;
  set;
 }
 public static string SelectedOption {
  get;
  set;
 }
 public string enteredText {
  get;
  set;
 }
 public Map < string, string > checkDataTypeMap {
  get;
  set;
 }
 public List < contact > lstContacts {
  get;
  set;
 }
 public transient Map < String, Schema.SObjectType > schemaMap = Schema.getGlobalDescribe();

 public contactSend() {

  options = new List < SelectOption > ();
  checkDataTypeMap = new Map < String, string > ();
  operatorOptions = new List < SelectOption > ();
  //To fetch the Contact fields by Describe call
  Selectoption sv = new SelectOption('--Please Select--', '--Please Select--');
  Options.add(sv);

  Map < String, Schema.SObjectField > ContactFieldsMap = SchemaMap.get('Contact').getDescribe().fields.getMap();
  for (Schema.SObjectField sField: ContactFieldsMap.Values()) {
   schema.describefieldresult fieldName = sfield.getDescribe();
   Schema.DisplayType fielddataType = sfield.getDescribe().getType();
   string fieldType = string.valueOf(fielddataType);
   SelectOption sp = new SelectOption(fieldName.getName(), fieldName.getName());
   checkDataTypeMap.put(fieldName.getName(), fieldType);
   options.add(sp);
   options.sort();
  }  
  //Add the filter conditons feteched from Custom settings to show in picklist
  SelectOption selOpt = new SelectOption('--Please Select--', '--Please Select--');
  operatorOptions.add(selOpt);

  List < CustomCondition1__c > filetConditions = CustomCondition1__c.getall().values();
  for (CustomCondition1__c Fcon: filetConditions) {
   SelectOption Fsp = new SelectOption(Fcon.Name, Fcon.Name);
   operatorOptions.add(Fsp);
   operatorOptions.sort();
  }
 }

 public PageReference createcon() {

  conlist = [SELECT id, LastName, AssistantName, AssistantPhone, Birthdate, Department, Description, Email, Fax, HomePhone, MailingAddress,
   MailingCity, MailingCountry, MailingPostalCode, MailingState, MailingStreet, MobilePhone, Name, OtherAddress, OtherCity,
   OtherCountry, OtherPhone, OtherPostalCode, OtherState, OtherStreet, Phone, Title,
       (SELECT id, email__c, Assistant_Name__c, Assistant_Phone__c, Birthdate__c, Contact__c,
        Department__c, Description__c, Fax__c, First_Name__c, Home_Phone__c, Mailing_City__c, Mailing_Country__c,
        Mailing_State_Province__c, Mailing_Street__c, Mailing_Zip_Postal_Code__c, Mobile_Phone__c,
        Other_City__c, Other_Country__c, Other_Phone__c, Other_State_Province__c, Other_Street__c,
        Other_Zip_Postal_Code__c, Phone__c, Title__c from Cons__r)
   From Contact where id in :lstSelectedCons limit 9999 
  ];

  list < Dummy_Contact__c > listDummyContactMain = new list < Dummy_Contact__c > ();
  list < Dummy_Contact__c > listDummyContactNew = new list < Dummy_Contact__c > ();

  for (Contact c: conlist) {
   if (c.Cons__r.size() == 0) {

    Dummy_Contact__c Dcobj = new Dummy_Contact__c();
    Dcobj.Name = c.LastName;
    Dcobj.Assistant_Name__c = c.AssistantName;
    Dcobj.Assistant_Phone__c = c.AssistantPhone;
    Dcobj.Birthdate__c = c.Birthdate;
    Dcobj.Description__c = c.Description;
    Dcobj.Department__c = c.Department;      
    Dcobj.Email__c = c.Email;
    Dcobj.Fax__c = c.Fax;
    Dcobj.Mailing_City__c = c.MailingCity;
    Dcobj.Mailing_Country__c = c.MailingCountry;
    Dcobj.Mailing_Zip_Postal_Code__c = c.MailingPostalCode;
    Dcobj.Mailing_State_Province__c = c.MailingState;
    Dcobj.Mailing_Street__c = c.MailingStreet;
    Dcobj.Other_City__c = c.OtherCity;
    Dcobj.Other_Country__c = c.OtherCountry;
    Dcobj.Other_Phone__c = c.OtherPhone;
    Dcobj.Other_Zip_Postal_Code__c = c.OtherPostalCode;
    Dcobj.Other_State_Province__c = c.OtherState;
    Dcobj.Other_Street__c = c.OtherStreet;
    Dcobj.Phone__c = c.Phone;
    Dcobj.Home_Phone__c = c.HomePhone;
    Dcobj.Mobile_Phone__c = c.MobilePhone;
    Dcobj.Title__c = c.Title;
    Dcobj.Contact__c = c.id;

    listDummyContactNew.add(Dcobj);

    //insert Dcobj;

   } else {
    listDummyContactMain.add(c.Cons__r[0]);
   }
  }
  if (!listDummyContactNew.isEmpty())
  try{
   insert listDummyContactNew;
   }
   catch(Exception e){
   system.debug(e.getMessage());
   }
  setIds = new set < id > ();
  listDummyContactMain.addAll(listDummyContactNew);

  for (Dummy_Contact__c dummy: listDummyContactMain) {
   String ids = '';
   ids += '\'';
   ids += String.valueOf(dummy.id);
   ids += '\'';
   //setIds.add(ids);
   setIds.add(dummy.id);
  }

  return null;
 }

 public pageReference getTeamMembers() {
  getslist();
  return null;
 }

 public List < SelectOption > getslist() {
  List < SelectOption > Slist = new List < SelectOption > ();
  Slist.add(new SelectOption('Not Contacted', 'Not Contacted'));
  Slist.add(new SelectOption('Contacted', 'Contacted'));
  Slist.add(new SelectOption('30 days', '30 days'));
  Slist.add(new SelectOption('60 days', '60 days'));
  Slist.add(new SelectOption('90 days', '90 days'));

  return Slist;
 }

 public pageReference Search() {
  ct = new List < contact > ();
  result = null;
  Date lastDate30 = System.today().addDays(-30);
  Date lastDate60 = System.today().addDays(-60);
  Date lastDate90 = System.today().addDays(-90);
  wdlist = new List < WrapDummy > ();
  wdlist1 = new List < WrapDummy > ();
  wdlist2 = new List < WrapDummy > ();

  string soql = 'SELECT id,LastName,AssistantName,AssistantPhone,Birthdate,Department,Description,Email,Fax,' + +
   'HomePhone,MailingAddress,MailingCity,MailingCountry,MailingPostalCode,MailingState,' + +
   'MailingStreet,MobilePhone,Name,firstname,OtherAddress,OtherCity,OtherCountry,OtherPhone,OtherPostalCode,' + +
   'OtherState,OtherStreet,Account.Name,LastModifiedDate,Phone,Title,Mail_Sent_Date__c,' + +
   '(SELECT Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,OwnerId,Phone__c,Title__c from Cons__r) From Contact where   ';
  string whereConditions = '';

  string resultQuery = '';
  if (string.isNotBlank(SelectedOption)) {
   whereConditions = SelectedOption;
  }
  if (string.isNotBlank(selectedOperatorOption)) {
   if (selectedOperatorOption == 'Equal to') {
    selectedOperatorOption = '=';
   } else {
    if (selectedOperatorOption == 'Not equal to') {
     selectedOperatorOption = '!=';
    }
   }
   whereConditions = whereConditions + ' ' + selectedOperatorOption;
   system.debug('enteredText ************ ' + enteredText);
   if (string.isNotBlank(enteredText) || calendarFieldVal != null) {
    string selectedDataType = checkDataTypeMap.get(SelectedOption);
    if (selectedDataType == 'BOOLEAN') {
     whereConditions = whereConditions + ' ' + enteredText;
    }
    if (selectedDataType == 'STRING')
     whereConditions = whereConditions + ' ' + '\'' + enteredText + '\'';
    if (selectedDataType == 'DATE') {
     whereConditions = whereConditions + ' ' + calendarFieldVal;
    }
   }
   if (selectedvalue == 'Not Contacted') {
    if (selectedOperatorOption == 'Select Value' || enteredText == '') {
     resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c = null';
        system.debug('hello1 :'+resultQuery);
    } else {
     resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c = null';
        system.debug('hello2 :'+resultQuery);
    }
    ct = database.query(resultQuery + ' Limit 10000');
       system.debug('ct sixe is1  :'+ct);
   }
  }
  if (selectedvalue == 'Contacted') {
   if (selectedOperatorOption == '--Please Select--' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c != null';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c != null';
   }
   ct = database.query(resultQuery + ' Limit 10000');
      system.debug('ct sixe is2  :'+ct);
  } else if (selectedvalue == '30 days') {
   if (selectedOperatorOption == 'Select Value' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate30';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate30';
   }
   ct = database.query(resultQuery + ' Limit 10000');
      system.debug('ct sixe is3  :'+ct);
  } else if (selectedvalue == '60 days') {
   if (selectedOperatorOption == 'Select Value' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate60';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate60';
   }
   ct = database.query(resultQuery + ' Limit 10000');
    system.debug('ct sixe is4  :'+ct);
  } else if (selectedvalue == '90 days')
  {
       if (selectedOperatorOption == 'Select Value' || enteredText == '') {
        resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate90';
    
       } else {
        resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate90';
       }
       ct = database.query(resultQuery + ' Limit 10000');
        system.debug('ct sixe is5  :'+ct);
  }

  dummylist = new List < Dummy_Contact__c > ();
  if (!ct.isEmpty()) {
   for (Contact cf: ct) {       
    for (Dummy_Contact__c df: cf.Cons__r) {
     DummyconId = df.id;
     dummymail = df.email__c;
     dummylist.add(df);
    }
   }   
  }
     for (Contact dt: ct)
        wdlist.add(new WrapDummy(dt));
  totalSize = wdlist.size();
     system.debug('total size is :'+totalSize);
  if ((counter + limitSize) <= totalSize) {
   for (Integer i = 0; i < limitSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  } else {
   for (Integer i = 0; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

  totalPages = Integer.valueOf(Math.ceil(totalSize / (Double) limitSize));
  return null;
 }

 public void beginning() {
system.debug('wdlist is :'+wdlist);
 
  wdlist1.clear();
  counter=0;
  if ((counter + limitSize) <= totalSize) {      
   for (Integer i = 0; i < limitSize; i++) {
       if(!wdlist.isEmpty()){
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
       }
   }
  } else {
   for (Integer i = 0; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }
 }
 public void nextP() {


  if (selectedAllProperties)
   selectedAllProperties = true;


  else
   selectedAllProperties = false;

  wdlist1.clear();
  counter = counter + limitSize;

  if ((counter + limitSize) <= totalSize) {
   for (Integer i = counter; i < (counter + limitSize); i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  } else {
   for (Integer i = counter; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

 }
 public void previousP() {
  if (selectedAllProperties)
   selectedAllProperties = true;

  else
   selectedAllProperties = false;


  wdlist1.clear();
  counter = counter - limitSize;
  for (Integer i = counter; i < (counter + limitSize); i++) {
   if (!wdlist.isEmpty()) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

 }
 public void lastP() {

system.debug('wdlist is :'+wdlist);
  wdlist1.clear();
  if (math.mod(totalSize, limitSize) == 0)
   counter = limitSize * ((totalSize / limitSize) - 1);
  else if (math.mod(totalSize, limitSize) != 0)
   counter = limitSize * ((totalSize / limitSize));
system.debug('counter :'+counter);
     system.debug('totalSize :'+totalSize);
  for (Integer i = counter - 1; i < totalSize - 1; i++) {
   if (!wdlist.isEmpty()) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }
 }
 public Boolean getDisableNext() {

  if ((counter + limitSize) >= totalSize)
   return true;
  else
   return false;
 }

 public Boolean getDisablePrevious() {

  if (counter == 0)
   return true;
  else
   return false;
 }
 public PageReference processselected() {
  Set < String > scon = new Set < String > ();
  lstSelectedCons = new set<Id>();
  SelectedDc = new List < Contact > ();
  set < Contact > ncts = new set < Contact > ();

  List < contact > updatecons = new List < Contact > ();
  if (!wdlist2.isEmpty()) {
   for (WrapDummy WrapDummyobj: wdlist2) {
    if (WrapDummyobj.selected == true) {
        lstSelectedCons.add(WrapDummyobj.Dcc.Id);
     SelectedDc.add(WrapDummyobj.Dcc);
     
     for (contact cts: SelectedDc) {
      cts.Mail_Sent_Date__c = Date.today();
      ncts.add(cts);
      // setids.add(cts.id);
    
     }
     //update ncts;                   
    }
   }

   if (!ncts.isEmpty()) {
    list < Contact > listNcts = new list < Contact > ();
    listNcts.addAll(ncts);
   }
   createcon();
  }
 // EmailTemplate templateId = [Select id from EmailTemplate where name = 'Sales: New Customer Email'];
  ContactUpdateURL__c mc = ContactUpdateURL__c.getall().values();
  string urlcode = mc.URLforContactUpdate__c;
  Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();

  if (SelectedDc.size() > 9) {
   for (contact c: SelectedDc) {
    scon.add(String.valueOf(c.id));
    system.debug(c.id);
    system.debug(c.cons__r);
     
    string cEmail = c.Email;
  
   }

   mailsend objmailsend = new mailsend();
   objmailsend.setIds = setIds;
   objmailsend.queryString = 'Select Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,OwnerId,Phone__c,Title__c   From Dummy_Contact__c';

   Database.executeBatch(objmailsend);
   result = 'Sending Emails are under process';
   for (Contact cs: SelectedDc) {
    cs.Mail_Sent_Date__c = Date.today();
    updatecons.add(cs);
   }


  } else {
  system.debug('Email to send contact is : '+SelectedDc);
   for (contact c: SelectedDc) {

    scon.add(String.valueOf(c.id));
    string cEmail = c.Email;
       system.debug('be fore dummt contatc is : '+cEmail);
    for (Dummy_Contact__c dd: c.cons__r) {
        system.debug('dummt contatc is : '+dd);
     id DummyconId = dd.id;
     string dummyname = dd.name;
     string dummymail = dd.email__c;
     string dummytitle = dd.Title__c;
     string dummyphone = dd.phone__c;
     string dummymobile = dd.Mobile_Phone__c;
     string dummyfax = dd.fax__c;
     string dummymailingstreet = dd.Mailing_Street__c;
     string dummypostalcode = dd.Mailing_Zip_Postal_Code__c;
     string dummymailingcity = dd.Mailing_City__c;
     string dummystate = dd.Mailing_State_Province__c;
     string dummycountry = dd.Mailing_Country__c;
      
     
        
     message.toAddresses = new String[] {
      dummymail
     };
     
     message.setTargetObjectId(c.id);
     message.optOutPolicy = 'FILTER';
     message.subject = 'Touch Contact';
     messageBody = '<html><body>Dear ' + dummyname + ',<br><br> ' + +

      'I' + 'm currently updating my contact database and want to make sure I have your current data right.' + +

      'Could you have a quick look at below info? If you would like to change or update certain information, just click the ' + 'Update Now' + ' link on the bottom of the email and save your changes when done.<br> <br>' + +

      'Last Name:' + dummyname + '<br><br>' + +

      'Email:' + dummymail + '<br><br>' + +

      'Current company:' + +'<br><br>' + +

      'Title:' + dummytitle + '<br><br>' + +

      'Phone:' + dummyphone + '<br> <br>' + +

      'Mobile:' + dummymobile + '<br><br>' + +

      'Fax:' + dummyfax + '<br><br>' + +

      'Street:' + dummymailingstreet + '<br><br>' + +

      'Postalcode:' + dummypostalcode + '<br><br>' + +

      'City:' + dummymailingcity + '<br><br>' + +

      'State/Province:' + dummystate + '<br><br>' + +

      'Country:' + dummycountry + '<br><br><br>' + +

      '<a href="' + urlcode + DummyconId + '">Update Now</a>' + '<br><br><br>' + +

      'Many thanks in advance, ' + '<br>' + +


      '' + UserInfo.getlastname() + ' </html></body>';


     message.setHtmlBody(messageBody);
     message.setSaveAsActivity(false);
     Messaging.SingleEmailMessage[] messages = new List < Messaging.SingleEmailMessage > {
      message
     };
     Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
  system.debug('hello email :'+results);
     if (results[0].success) {
      c.Mail_Sent_Date__c = Date.today();
      updatecons.add(c);
      result = 'Email Sent';
     } else {
      string result = 'Email Not Sent';
     }
     break;
    }
   }

  }
  if(!updatecons.isEmpty())
  update updatecons;
  if (SelectedDc.isEmpty()) {
   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please Select value'));
   return null;
  }

  pageReference pr = new PageReference('/apex/ContactMassMail1');
  pr.setRedirect(true);
  return pr;
 }

 public class WrapDummy {
  public Contact Dcc {
   set;
   get;
  }
  public Boolean selected {
   set;
   get;
  }
  public Decimal quantity {
   set;
   get;
  }
  public WrapDummy(Contact dt) {
   Dcc = dt;
   selected = false;
   quantity = 0;
  }
 }
 public pageReference enableCalendarTextBox() {
  string selDataType = checkDataTypeMap.get(SelectedOption);
  if (selDataType == 'DATE') {
   showCalendarField = true;
  } else {
   showCalendarField = false;
  }
  return null;
 }
}
=====================vf ==================
<apex:page showHeader="true" sidebar="false" controller="contactSend"  docType="html-5.0" id="mypage"  tabStyle="Contact" >
   <style type = "text/css">
      .pbs{
      color: red;
      }
   </style>
        
   <apex:form id="fm"  style="color:blue;">
      <apex:pageBlock id="pb" >
         <apex:pageMessages ></apex:pageMessages>
         <apex:pageBlockSection collapsible="false" id="pbs" >
            <apex:outputLabel >Last Modified Date From</apex:outputLabel>
            <apex:input type="date" value="{!dat}"    />
            <apex:outputLabel >Last Modified Date To</apex:outputLabel>
            <apex:input type="date"  value="{!to}"  />
            <apex:outputLabel >Contact Last sent</apex:outputLabel>
            <apex:selectList value="{!selectedvalue}" multiselect="false" size="1">
               <apex:selectOptions value="{!Slist}"></apex:selectOptions>
            </apex:selectList>
         </apex:pageBlockSection>
         <apex:pageBlock id="filt">
            <apex:outputLabel value="Select Field"  />
            :   
            <apex:selectList value="{!SelectedOption}" size="1">
                <apex:selectOptions value="{!Options}"  />
                  <apex:actionSupport event="onchange"  action="{!enableCalendarTextBox}" reRender="calendarField"   />              
            </apex:selectList>
            <apex:selectList value="{!selectedOperatorOption}" size="1" >
               <apex:selectOptions value="{!operatorOptions}" >                  
               </apex:selectOptions>
            </apex:selectList>   
             
            <apex:outputPanel id="calendarField">                
               <apex:input type="date" value="{!calendarFieldVal}"  style="{!if(showCalendarField,'display:hidden;', 'display:none')}"   />
                <apex:inputText value="{!enteredText}" style="{!if(showCalendarField,'display:none;', 'display:hidden')}" />                
            </apex:outputPanel>            
         </apex:pageBlock>
         <div class="pbs"  >
            <apex:pageBlockButtons location="bottom" > 
               <div style="float:None;align:center;margin-left:20%;"> 
               <apex:commandButton value="Search" action="{!Search}" status="actStatusId1" style="background:powderblue; width:100px;" rerender="table1, pb2,fm,pb,pi">
                  <apex:actionsupport event="oncomplete" rerender=" pb1"/>
               </apex:commandButton>
               </div>
            </apex:pageBlockButtons>
         </div>
      </apex:pageBlock>
      <apex:pageBlock id="pb1" >
         <apex:actionStatus id="actStatusId1" startText=" Processing the stuff "  >
            <apex:facet name="start" >
               <img src="/img/loading.gif" />
            </apex:facet>
         </apex:actionStatus>
         
      
          
        <apex:pageBlock title="Contact Details" id="noRec" rendered="{! IF(wdlist1!= null && wdlist1.size ==0 , true, false)}" >
            <apex:outputPanel >
                <h1>No Records Found </h1>
            </apex:outputPanel>
            </apex:pageBlock>
               <apex:pageBlockTable value="{!wdlist1}" var="c" id="table1"   > 
            <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox value="{!selectedAllProperties}" onclick="selectAllCheckboxes(this)" rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}" />
                    </apex:facet> 
                    <apex:inputCheckbox value="{!c.selected}" styleClass="cbStyleClass" onclick="doCheckboxChange(this,'{!c.Dcc.Id}')" />
                </apex:column>
            <apex:column value="{!c.Dcc.Lastname}"/>
            <apex:column value="{!c.Dcc.Firstname}"/>
            <apex:column value="{!c.Dcc.Account.Name}"/>
            <apex:column value="{!c.Dcc.Email}"/>
            <apex:column value="{!c.Dcc.LastModifiedDate}"/>
         </apex:pageBlockTable>
         
       <apex:outputPanel rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}">
                <br/>
                <!-- count of selected items -->
                <apex:outputLabel value="Total Number of Records :{!totalSize } " />
            </apex:outputPanel>
              <br/> 
         
          <apex:outputPanel styleClass="center" rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}" id="button" >              
                         <apex:commandButton value="First" action="{!beginning}" disabled="{!DisablePrevious}"  />
                         <apex:commandButton value="Previous" action="{!previousP}" disabled="{!DisablePrevious}"    />
                         <apex:commandButton value="Next" action="{!nextP}" disabled="{!DisableNext}"  />
                         <apex:commandButton value="Last" action="{!lastP}" disabled="{!DisableNext}"    />                                 
          </apex:outputPanel>
        <apex:pageBlockButtons rendered="{!wdlist1!=null}"  id="myButtons"  >
          <div style="float:None;align:center;margin-left:20%;"> 
            <apex:actionStatus id="mySaveStatus1">
               <apex:facet name="stop">
                  <apex:commandButton value="Send Mail" action="{!processselected}" style="background:powderblue; width:100px;" reRender="pb2,pb" status="mySaveStatus1"/>
               </apex:facet>
               <apex:facet name="start">
                  <apex:commandButton value="Processing..." status="mySaveStatus1" disabled="true"/>
               </apex:facet>
            </apex:actionStatus> 
           </div>    
         </apex:pageBlockButtons>
         
         
      </apex:pageBlock>
     
   </apex:form>
   
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
       
    //function to handle checkbox selection
    function doCheckboxChange(cb,itemId)
    {
        if(cb.selected==true){
            aSelectItem(itemId);
        }
        else{
            aDeselectItem(itemId);
        }        
    }    
    function selectAllCheckboxes(obj){
        $(".cbStyleClass").each(function(index, item){
            item.checked = obj.checked;
        });
        isSelectAllItem(obj.checked);
    }
    
    function updateTextChange(obj, itemId){
        
        updateQuantity(itemId, $(obj).val());
    }
    </script>
   </apex:page>

 
prateek jainprateek jain
Hi
Please Explain what you are trying  to achieve with this code i.e. scenario
Thanks
 
Pradeep dPradeep d

Hi Prateek,

Thanks for ur reply.

Here's the scenario : I want to update contacts by them, as per salesforce standards site users can't update contact object, for that i created one dummy object along with same standard contact fields in dummy obj.

based on the last modified date and filtering condition contact list has to be fetched on page with checkboxes,

once u select the records and click on the send mail, duplicate contact record has to be created, that record id has to be added into portal link, that link has to send to contacts. by clicking on that link contact can update their info.

if the selected list size is more than 9 then it'll call batch 

Challenges : fetching list causing view state error, if i select more than 1000 records Apex cpu time out error is rendering.

kindly provide suitable suggestions for these issues

Thanks,

Pdeep.

 

 

 

prateek jainprateek jain
Hi 
Nice to help You
Have you tried Flow to implement above scenario. It would help you out
Meanwhile, I have to check your code
My Quick  suggestion would be  use flow I have used it to create similar type of scenario
If you require any help let me know .I am happy to help you out
Thanks 
 
Pradeep dPradeep d
By using flows, we cant send 5000 emails per day, v cant call batch too.