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
ankur khattriankur khattri 

filter criteria view

there is a mass update button in the cases.And when mass update button is clicked the fliter criteria changes for eg:-if we select all cases then it changes to all open cases.Is there any way to keep the same view after mass update is done(there is a button of mass update in js.)
Amit Chaudhary 8Amit Chaudhary 8
There is something which you i did for mass delete. I hope that will help you
1) http://amitsalesforce.blogspot.in/2016/04/mass-delete-delete-from-list-view.html

You can also try below app exchange product for mass update
1) https://appexchange.salesforce.com/listingDetail?listingId=a0N300000018mbBEAQ

NOTE:- above app is Unmanaged Package you can also change code according to your requirement

Let us know if this will help you

Thanks
Amit Chaudhary
JyothsnaJyothsna (Salesforce Developers) 
Hi Ankur,

Please check the below sample code for bulkupdate.

Visualforce Page
 
<apex:page controller="BulkDeletecont" showHeader="false">
 <apex:form >
 <apex:pageBlock rendered="{!delupdate}">
 
 <apex:pageBlockButtons location="bottom">
 <apex:commandButton value="BulkDelete" action="{!deleterec}"/>
 <apex:commandButton value="BulkUpdate" action="{!UpdateRec}"/>
 </apex:pageBlockButtons>
 <apex:pageBlockTable value="{!course1}" var="ct">
 <apex:column >
 <apex:inputCheckbox value="{!ct.ck}" />
 </apex:column>
 <apex:column headerValue="Course name">
 <apex:outputField value="{!ct.wp.name}"/>
 </apex:column>
 <apex:column headerValue="Course fee">
 <apex:outputField value="{!ct.wp.course_fee__c}"/>
 </apex:column>
 <apex:column headerValue="Duration">
 <apex:outputField value="{!ct.wp.Duration__c}"/>
 </apex:column>
 </apex:pageBlockTable>
 
 <!-- update records-->
 </apex:pageBlock>
 <apex:pageBlock title="Bulk update records" rendered="{!updateblock}">  
 <apex:pageBlockButtons location="bottom">
   <apex:commandButton value="Updaterecs" action="{!UpdateRec1}"/>
 </apex:pageBlockButtons>
 <apex:pageBlockTable value="{!updt}" var="ct1">

 <apex:column headerValue="Course name">
 <apex:inputField value="{!ct1.name}"/>
 </apex:column>
 <apex:column headerValue="Course fee">
 <apex:inputField value="{!ct1.course_fee__c}"/>
 </apex:column>
 <apex:column headerValue="Duration">
 <apex:inputField value="{!ct1.Duration__c}"/>
 </apex:column>
 </apex:pageBlockTable>
 </apex:pageBlock>
 </apex:form>
</apex:page>


Controller
 
public with sharing class BulkDeletecont {

    public boolean delupdate { get; set; }

   // public list<wrapper1> course11 { get; set; }

    public boolean updateblock { get; set; }
    
    public list<wrapper1> course1 { get; set; }
    
     public  list<course__c> updt{set; get;}
    
      // constructor
     public BulkDeletecont(){
    delupdate =true;
    updateblock=false;
     course1=new list<wrapper1>();
    list<course__c> course2=[select name,course_fee__c,Duration__c from course__c];
    for(integer index=0; index<course2.size(); index++)
    {
       course1.add(new wrapper1(course2[index]));
    }
    }//end constructor
   // bulkdelete  records

    public PageReference deleterec() {
     list<course__c> del=new list<course__c>();
         for(integer index=0; index<course1.size(); index++){
         if(course1[index].ck==true){
         del.add(course1[index].wp);
         }
         }
         delete del;
         course1=new list<wrapper1>();
         list<course__c> course2=[select name,course_fee__c,Duration__c from course__c];
    for(integer index=0; index<course2.size(); index++)
    {
       course1.add(new wrapper1(course2[index]));
    }
        return null;
    }
    //bulkupdate records
    public PageReference UpdateRec() {
  updateblock =true;
   updt=new list<course__c>();
         for(integer index=0; index<course1.size(); index++){
         if(course1[index].ck==true){
         updt.add(course1[index].wp);
         }
         }
         
        return null;
   }
    public PageReference UpdateRec1() {
        update updt;
        updateblock =false;
        delupdate=true;
        course1=new list<wrapper1>();
    list<course__c> course2=[select name,course_fee__c,Duration__c from course__c];
    for(integer index=0; index<course2.size(); index++)
    {
       course1.add(new wrapper1(course2[index]));
    }
        
        return null;
    }
    //wrapper class
        public class wrapper1{
        public course__c wp{get; set;}
        public boolean ck{get; set;}
          public wrapper1(course__c co){
          wp=co;
          ck=false;
          }
        }
     
 
  

}

Output

User-added image




User-added image


Hope this helps you!
Best Regards,
Jyothsna
JyothsnaJyothsna (Salesforce Developers) 
Hi Ankur,
Please check the below JS sample code for massupdate

1.Create a ListButton on account.

Please write the below JS.
{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")}  
 var records = {!GETRECORDIDS($ObjectType.Account)};   
 var updateRecords = [];   
 if (records[0] == null)   
 {   
  alert("Please select at least one Account")   
 }   
 else   
 {   
  for (var i=0; i<records.length; i++)   
  {   
   var acc = new sforce.SObject("Account");   
   acc.id = records[i];   
   acc.Type = "Customer";   
   updateRecords.push(acc);   
  }   
  result = sforce.connection.update(updateRecords);   
  window.location.href = "/001";   
 }

Hope this helps you!
Best Regards,
Jyothsna