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
vamsi krishna 106vamsi krishna 106 

Is it Possible to refresh Contact page when same contact was updated by bacth apex class?

Contact has open and i have batch class which update the same contact when bacth apex class updated then i need to refresh the contact details page. Either by using Lightning component or any other 

Any suggestions?

Thanks
Vamsikrishna B.
AbhishekAbhishek (Salesforce Developers) 
Hi Vamsi,

Try this

global class BatchContactUpdate implements Database.Batchable<sObject>{

    List <Account> mapAccount = new List <Account> ();
    List <Contact> contactlist1 = new List <Contact> ();
    
    global BatchContactUpdate(List <Account> AccountUpdate) {
        mapAccount=AccountUpdate;
        
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return DataBase.getQueryLocator([SELECT Id, AccountID
                                         FROM Contact
                                         WHERE AccountID IN :mapAccount
                                        ]);
    }
    global void execute(Database.BatchableContext BC , List <Contact> contactlist) {
        for (Account acct : mapAccount){ 
            for (Contact con : contactList){
                if (con.AccountID == acct.Id){
                        contactlist1.add(new Contact(
                            Id = con.Id,
                           );
                    }
            }   
        }
        
         update contactlist1;
    } 
    global void finish(Database.BatchableContext BC){
        
    }
}


For your reference,

https://developer.salesforce.com/forums/?id=906F0000000kE3fIAE

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.