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:
- Identify the Job: Locate the specific scheduled job you wish to modify.
- Delete the Existing Job: Remove the current scheduled instance.
- 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:
- Navigate to Setup.
- In the Quick Find box, type
Scheduled Jobs
and select Scheduled Jobs under "Jobs". - 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 theSubmitted By
user. - Click the Del link next to the relevant job.
- 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
):- Navigate to Setup.
- In the Quick Find box, type
Apex Classes
and select Apex Classes. - Click the Schedule Apex button.
- Provide a
Job Name
. - Select the
Apex Class
you want to schedule. - Choose the
Frequency
(Weekly or Monthly) and set theStart
andEnd Dates
. - Select the preferred
Time
for execution. - Click Save.
-
Via Developer Console (for immediate scheduling or more complex logic):
- Open the Developer Console (accessible from the gear icon in the top right).
- Go to Debug > Open Execute Anonymous Window.
- 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);
- Click Execute.
2. Scheduled Reports and Dashboards
Report and dashboard subscriptions also follow a similar re-configuration pattern.
2.1. Managing Report Subscriptions:
- Go to the Reports tab.
- Find the report you want to modify.
- Click the down arrow next to the report name and select Subscribe (or Edit Subscription if one exists).
- In the subscription window, you can typically
Edit
orDelete
the existing schedule. - If you
Delete
it, you can thenSubscribe
again with new settings (frequency, time, recipients, conditions).
2.2. Managing Dashboard Subscriptions:
- Go to the Dashboards tab.
- Find the dashboard you want to modify.
- Click the down arrow next to the dashboard name and select Subscribe.
- Similar to reports, you can
Edit
orDelete
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.
- Navigate to Setup.
- In the Quick Find box, type
Data Export
and select Data Export under "Data". - If an export is scheduled, you will see details under "Scheduled Export".
- To change the schedule, you must first Unschedule Export.
- 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.