You need to sign in to do that
Don't have an account?
How to execute a batch Apex
Hello
I have some Batch Apex which I need to execute once, as part of the initialisation of existing Contact records for a new development, but I do not know how to run it. Support have been less than helpful. Can anyone on this board help, please?
I mean I need to know how best to execute the Apex script that contains this code:
MailingPreferencesBatchUpdater mpbu = new MailingPreferencesBatchUpdater();
Database.executeBatch(mpbu);
I have consideredputtin gthe code in a Trigger on some object type that we do not currently use (so I would create an instance of that object to trigger the batch), but that feels wrong.
I have considered the Apex Scheduler, but I do not have access to that and I do not really know whether it would do the job.
It's getting urgent as we go Live with this project at the end of this year.
Thanks
Steve
You are right to be hesitant/cautious with adding this to a trigger given the limit of concurrent processes and what that would mean to your user's normal operations.
Your best bet for now is to create a simple visualforce page with a button that initiates the process.
All Answers
You are right to be hesitant/cautious with adding this to a trigger given the limit of concurrent processes and what that would mean to your user's normal operations.
Your best bet for now is to create a simple visualforce page with a button that initiates the process.
Hi Andrew
Thanks for that. I've never done a Visualforce page, but that "simple" sounds promising! I'll have a stab at it tomorrow or Monday and see how I get on.
Steve
In general yes it would be sensible to check how many batches are running, but in this case I am running it as a one-off; we have no other batches.
I wrote a simple Visualforce page with a button to run the batch and it did the trick.
Thanks for the help
Steve