Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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;
 }
share|improve this question
add comment

2 Answers 2

http://www.tehnrd.com/batch-apex-status-bar/

This is a nice Batch Status bar you might want to look into

share|improve this answer
add comment

The better approach for this would be use an email alert to send to the User once a batch is completed .

If you want on the page an action poller or streaming API is the only way to detect this and show on to the page the moment batch completes .

share|improve this answer
    
Yes i know to use email, but i like to show a message on VF page after the batch process is completed, is this possible. –  AnuRaj Dec 17 '12 at 4:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.