I'm trying to figure out the best way to transfer Account ownership of certain accounts once a day. I would use declarative tools but can't because the data that would fire the automation is coming from a couple of custom formula fields. I'm confused whether I need to write a scheduled class, a batch class or a scheduled batch class. I've gone through trailhead and sfdc help docs and am still unclear on how to accomplish this. Any pointers on how to get started are much appreciated.
-
2In short, you will need a batch class to change the ownership, scheduled at the end of the day.– Jayant DasFeb 26, 2019 at 22:58
-
1Changing ownership on a daily, automated basis is unusual enough to make me wonder if this could be an x-y problem.. is it possible some other visibility solution could solve your underlying objective?– David Reed ♦Feb 26, 2019 at 23:18
-
2you might look at Doug Ayers' Mass Action Scheduler (Appexchange - Lightning only)– cropredyFeb 27, 2019 at 0:46
1 Answer
Try this
global class SchedulableClass implements schedulable
{
global void execute(SchedulableContext sc)
{
Batchclass b = new Batchclass (); //your batch class
Database.executebatch(b);
}
}
In the Apex Class page (Setup -> Apex Classes) there is a button called "Schedule Apex". Click that and schedule this apex class on a daily basis
-
What does this do? How is this moving the account's owner? I would recommend you both expand on the answer and also add explanations so the OP actually derives a benefit from your answer. Feb 27, 2019 at 1:00