Ora

How Do I Edit Scheduled Jobs in Salesforce?

Published in Salesforce Job Management 5 mins read

In Salesforce, you cannot directly edit or modify an existing scheduled job. To make any changes to a job that has already been scheduled, you must first delete the existing job and then create a new one with your desired modifications. This approach ensures that all updates are applied correctly and that the job runs according to the new specifications.

Understanding Salesforce Scheduled Jobs

Scheduled jobs in Salesforce are automated processes designed to run at specific times or intervals. These can include:

  • Apex Scheduled Jobs: Custom Apex code executed periodically.
  • Data Export Service: Automated exports of your Salesforce data.
  • Scheduled Reports and Dashboards: Reports or dashboards automatically run and emailed to users.
  • Platform Event Replay Proxies: Managing the replay of platform events.
  • Other system-level processes or jobs from installed managed packages.

While the exact steps for managing these differ, the core principle remains: direct in-place editing is not an option for their underlying schedules or definitions.

The Process: Delete and Reschedule

To "edit" a scheduled job in Salesforce, follow these general steps:

  1. Identify the Job: Locate the specific scheduled job you wish to modify.
  2. Delete the Existing Job: Remove the current scheduled instance.
  3. Reschedule a New Job: Create a new scheduled job with all the desired changes (e.g., different execution time, updated Apex class, new report parameters).

Step-by-Step Guide for Common Scheduled Jobs

Here’s how to manage various types of scheduled jobs in Salesforce:

1. Apex Scheduled Jobs

Apex scheduled jobs are the most common type of custom automation.

1.1. Deleting an Apex Scheduled Job:

  1. Navigate to Setup.
  2. In the Quick Find box, type Scheduled Jobs and select Scheduled Jobs under "Jobs".
  3. You will see a list of all currently scheduled jobs. Locate the job you want to modify. It's usually identifiable by the Job Name or the Submitted By user.
  4. Click the Del link next to the relevant job.
  5. Confirm the deletion.

1.2. Rescheduling an Apex Job with New Changes:

After deleting, you can schedule a new job with updated Apex code or different parameters.

  • Via Apex Scheduler UI (for classes implementing Schedulable):

    1. Navigate to Setup.
    2. In the Quick Find box, type Apex Classes and select Apex Classes.
    3. Click the Schedule Apex button.
    4. Provide a Job Name.
    5. Select the Apex Class you want to schedule.
    6. Choose the Frequency (Weekly or Monthly) and set the Start and End Dates.
    7. Select the preferred Time for execution.
    8. Click Save.
  • Via Developer Console (for immediate scheduling or more complex logic):

    1. Open the Developer Console (accessible from the gear icon in the top right).
    2. Go to Debug > Open Execute Anonymous Window.
    3. Enter the Apex code to schedule your class. For example:
      MyScheduledClass myJob = new MyScheduledClass();
      // Schedules the job to run every day at 3:00 AM UTC
      // Cron expression format: Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
      // '0 0 3 * * ?' means "at 0 seconds, 0 minutes, 3 hours (3 AM), any day of the month, any month, any day of the week."
      String cronExp = '0 0 3 * * ?'; // Example: Run every day at 3 AM UTC
      System.schedule('MyUpdatedDailyJob', cronExp, myJob);
      System.debug('Scheduled "MyUpdatedDailyJob" to run with cron expression: ' + cronExp);
    4. Click Execute.

2. Scheduled Reports and Dashboards

Report and dashboard subscriptions also follow a similar re-configuration pattern.

2.1. Managing Report Subscriptions:

  1. Go to the Reports tab.
  2. Find the report you want to modify.
  3. Click the down arrow next to the report name and select Subscribe (or Edit Subscription if one exists).
  4. In the subscription window, you can typically Edit or Delete the existing schedule.
  5. If you Delete it, you can then Subscribe again with new settings (frequency, time, recipients, conditions).

2.2. Managing Dashboard Subscriptions:

  1. Go to the Dashboards tab.
  2. Find the dashboard you want to modify.
  3. Click the down arrow next to the dashboard name and select Subscribe.
  4. Similar to reports, you can Edit or Delete the existing subscription and then create a new one with updated details.

3. Data Export Service

The Data Export Service allows you to schedule weekly or monthly backups of your data.

  1. Navigate to Setup.
  2. In the Quick Find box, type Data Export and select Data Export under "Data".
  3. If an export is scheduled, you will see details under "Scheduled Export".
  4. To change the schedule, you must first Unschedule Export.
  5. After unscheduling, you can then click Schedule Export again to set up a new export with different frequencies, start dates, and included objects.

Key Considerations for Managing Scheduled Jobs

  • Dependencies: Be aware of any other processes or users that rely on the output or timing of your scheduled job.
  • Permissions: Ensure you have the necessary permissions (e.g., "Schedule Apex" permission) to delete and reschedule jobs.
  • Timing and Downtime: If a job has a critical execution window, plan your deletion and rescheduling carefully to minimize any gaps in processing.
  • Monitoring: After rescheduling, monitor the new job in the "Scheduled Jobs" and "Apex Jobs" pages to ensure it runs as expected.
  • Error Handling: Ensure your Apex classes or processes have robust error handling, especially when dealing with scheduled operations.

Scenario Examples

The table below illustrates common scenarios and the actions required:

Scenario Old Schedule (Example) Desired Change (Example) Action Required
Apex Job Every Monday 8 AM UTC Change to daily 9 PM UTC Delete old job, reschedule new Apex job.
Apex Job Runs MyClass_V1 Run updated MyClass_V2 Delete old job, reschedule new Apex job with MyClass_V2.
Report Subscription Weekly, Fridays 5 PM Change to monthly, first day 9 AM Edit/Delete old subscription, create new.
Data Export Service Weekly, Sunday 2 AM Change to monthly, 1st of month Unschedule export, schedule new export.

By understanding that "editing" a scheduled job in Salesforce primarily involves a delete-and-recreate process, you can effectively manage and update your automated processes.