I need to run a class in apex 30 minutes after updating a custom field of custom object, what can I use?

  • You can do that using process builder schduled action,trailhead.salesforce.com/en/content/learn/modules/… – Pranay Jaiswal Jan 22 '19 at 18:24
  • If you want code only solution. Apex Scheduler is what you should look into – Pranay Jaiswal Jan 22 '19 at 18:24
  • 6
    What do you want the code to do? If it can be achieved via Workflow Rule, you may consider Time Based Workflow Rules, by far the simplest approach. – Adrian Larson Jan 22 '19 at 18:26
  • What is the purpose of that Apex Class? If you can accomplish the actions with a Time Based Process Builder / Workflow, great, but if not maybe add call your Apex class from Process builder or trigger (be really cautious and bulkify your code) – Raspi Jan 26 '19 at 23:57

You might be able to achieve what you want using something called a "Trigger". Triggers are used to execute code after a database operation on a row, like an update, and it looks like this:

trigger HelloWorldTrigger on Account (before insert) {
    System.debug('Hello World!');


In this trigger, you can then schedule an APEX Job to be run 30 minutes later as explained in this trailhead:


The code for it should look like this

global class SomeClass implements Schedulable {
    global void execute(SchedulableContext ctx) {
        // awesome code here

and then, in your trigger, you would have something like that to call it

// Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
String sch = '20 30 8 10 2 ?';
String jobID = System.schedule('Remind Opp Owners', sch, reminder);
|improve this answer|||||
  • 6
    You should exercise caution while scheduling classes from a trigger as you may hit the limits if bulk processing is not considered. – Jayant Das Jan 22 '19 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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