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
SilverSurferSilverSurfer 

Calling batch apex process from a controller

I want to invoke a btach process from a VF page controller. The results are to be displayed to the user for the further processing. I did try out calling it the normal way as :

 

ID batchprocessid = Database.executeBatch(new BatchableClass(query));

 

It is not working. Any pointers will be highly appreciated. Thanks in advance.

Regards.

bob_buzzardbob_buzzard

According to the apex docs:

 

 

Important: When you call Database.executeBatch, Salesforce.com only adds the process to the queue at the
scheduled time. Actual execution may be delayed based on service availability.

 

Important: When you call Database.executeBatch, Salesforce.com only adds the process to the queue at thescheduled time. Actual execution may be delayed based on service availability.

 

You can track the progress of the job using a query such as the following:

 

 

AsyncApexJob aaj = [SELECT Id, Status, JobItemsProcessed, TotalJobItems, NumberOfErrors
FROM AsyncApexJob WHERE ID =: batchprocessid ];

 

 

SilverSurferSilverSurfer

Hi ,

 

Thanks for your reply. My basic concern is to invoke a batch process from a VF page controller. I want to display the results of a batch process in a VF page using a custom controller. I am not able to pass the list to the batch process.

 

Regards.

bob_buzzardbob_buzzard

Can you clarify what you mean by "I am not able to pass the list to the batch process."?

 

What list is this?