I need to show a alert message after the batch process is completed. For that i have create a static boolean varible in a class and in my batch process finish i am calling this varible and changing the value of the boolean varible, when the process is completed. I am using a apex button to run the batch process. The value of the boolean is get changed but i am not able to show the message when the process is completed. my batch file
global void finish(Database.BatchableContext BC)
{
System.debug('Batch Process Completed in finish 1');
BatchUpdate_info.Updateresult = true;
System.debug('Batch Process Completed in finish 2');
system.debug('Batch process result ' + BatchUpdate_info.Updateresult);
}
} static var
public class BatchUpdate_info {
public static boolean Updateresult = false; }
VF page to run the batch file
<apex:page controller="ctrl_ConatctBatch">
<apex:messages />
<apex:form >
<apex:commandButton value="Run Batch Process" action="{!getRunBatch}" />
</apex:form>
</apex:page>
Controller
public class ctrl_ConatctBatch
{
public String getRunBatch()
{
contact_BatchProcess cb = new contact_BatchProcess ();
Database.executeBatch(cb, 200);
System.debug('Result : In getRunBatch function');
if(BatchUpdate_info.Updateresult == true){
System.debug('Batch Process Completed');
ApexPages.Message dupeMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Batch Process Completed');
BatchUpdate_info.Updateresult = false;
System.debug('Batch Update result ' + BatchUpdate_info.Updateresult);
}
return null;
}