Questions tagged [scheduled-apex]

Issues with writing, running, or testing scheduled Apex code, using the Schedulable interface.

Filter by
Sorted by
Tagged with
103 votes
1 answer
4k views

When are the Queueable/Batchable penalties going to be enforced?

According to The New Apex Queueable Interface, from October 2014, we were told that chained Queueable calls would be exponentially delayed up to 64 seconds, chaining Batches would be exponentially ...
sfdcfox's user avatar
  • 491k
75 votes
1 answer
6k views

InstallHandler runs under a special ghost user. What rights does it have?

When you install a managed package with a post-install script, Salesforce creates a special ghost user under which all of the post install activities occur. I think this is undocumented. Here are some ...
Matt and Neil's user avatar
63 votes
6 answers
96k views

How to run a scheduled job every 15 minutes?

Using the salesforce GUI it seams impossible to schedule a job every 15 minutes. Or more than once a day.
Christian Deckert's user avatar
44 votes
4 answers
22k views

Scheduled reports as attachment

Is there any workaround to send out scheduled reports as Excel attachment than actually embedding it within an email? Salesforce scheduled reports embeds the report in email making further drill down ...
Rao's user avatar
  • 16.7k
38 votes
2 answers
5k views

Ghost Schedulable Classes Blocking Deployment

Recently I've been running into issues where deployments were blocked due to a Schedulable job pending or in progress when I'd already cleared the Schedulable job from that class. Any tips for ...
Ralph Callaway's user avatar
35 votes
3 answers
11k views

How to deploy apex classes that are scheduled

This is related to Is there any way to unschedule an apex scheduled job programmatically?. I noticed user320 mentioned there is a way to use Type.forName to decouple your classes from the scheduled ...
Daniel Hoechst's user avatar
35 votes
2 answers
10k views

Is there any way to unschedule an apex scheduled job programmatically?

Is there any way, either using apex or the API to unschedule a scheduled job?
greenstork's user avatar
  • 14.8k
28 votes
3 answers
20k views

Scheduling an Apex Job through the ui

I am not sure if my memory is failing me, but I was sure there was a way to schedule an Apex Job through the Salesforce UI. The documentation here only makes mention of using the cron syntax. and ...
Daniel Blackhall's user avatar
26 votes
6 answers
38k views

Calling future method from Batch

I have a requirement where a future method need to be called from batch apex ,I came across various articles stating that a future method could not be called from the batch. Is there any alternate ...
Manoj Chandran's user avatar
25 votes
6 answers
11k views

Scheduled batch jobs and durability

I have a process that runs scheduled Apex quite regularly as a batch job manager. This process runs on a one-time schedule, and looks into a batch job table (custom object). If it finds work to do, it ...
jkraybill's user avatar
  • 11.2k
25 votes
2 answers
5k views

How to run Apex code every 5 minutes in 2016?

From a naive read of these questions and answers: 2012 - Are there best practices to get scheduled apex scheduled to run faster than once per hour? 2013 - What will be the cron expression for ...
Keith C's user avatar
  • 136k
25 votes
1 answer
19k views

How to get UserInfo.getSessionId() in Scheduler/Batch

I am building sfdc application that required me to call and do add/update using Http method at vendor application in external server daily. They created one account for me in their application. In ...
unidha's user avatar
  • 2,552
24 votes
3 answers
69k views

Schedule Hourly Batch Using Cron Expression - Start on Abritrary Day of Month

Can we schedule a batch apex using Cron expression starting from some arbitrary day of the month, say starting from 9th of this month I need to schedule an hourly batch.
codebandit's user avatar
  • 1,773
21 votes
3 answers
51k views

How to Test Messaging.sendEmail

Looking for some help/advice in writing a test class. The class I need to test is an apex class to schedule a report that needs to be sent to an external email address once a month as a .csv ...
mlpSFadmin's user avatar
21 votes
5 answers
77k views

How can I query the class which the schedule job will call

I am trying to get the name of the schedule / batch classes called by the schedule job Trying this select Id,CronJobDetailId,CronJobDetail.Name, NextFireTime,PreviousFireTime,State,StartTime,...
Michael Gill's user avatar
  • 2,202
20 votes
4 answers
25k views

Passing Parameter Into Schedulable Class

Is there a way to pass a parameter into a schedulable class execute method? We were trying to pass a string from another scheduled class into this scheduled class but it looks like we can't do that? ...
ddeve's user avatar
  • 1,606
18 votes
4 answers
22k views

Cannot delete AsyncApexJob using System.abortJob

I'm facing the "ghost" job issue in an organization (thankfully is a sandbox). I had a class scheduled to run in a daily basis, and it was working fine, until I accidentally scheduled it again (2 jobs ...
Renato Oliveira's user avatar
18 votes
1 answer
26k views

Error System.CalloutException: Callout from scheduled Apex not supported

i have created a schedulable class which has to trigger a batch job. The run method for the batch class will get list of data to process from a webservice callout. Now, i got the exception below. Any ...
Bforce's user avatar
  • 6,828
16 votes
5 answers
33k views

How to test a scheduler which runs a batch?

I have a scheduler class which calls a batch Apex. I want to write an Apex test for the scheduler class. However, the test fails. It seems that the testing framework does not execute the batch class. ...
Riadh Mankai's user avatar
  • 1,088
16 votes
3 answers
21k views

Best practices for monitoring Scheduled Apex and Batch Apex?

We have multiple Apex jobs running, both from Schedulable and Batchable code. While an attentive SA could examine the Apex Jobs list to check that everything is OK, it seems a better idea to have ...
Keith C's user avatar
  • 136k
16 votes
2 answers
3k views

Does Test.stopTest() ensure a System.Schedule/Database.Batchable completes in a test?

I am struggling to successfully test some code that is essentially the same as the code here Apex test class for schedulable class that checks for 5 batches running already. I can get the System....
Keith C's user avatar
  • 136k
15 votes
1 answer
12k views

Using Batch Apex on millions of records

Part of our app behaviour is going over millions on records and updating their data. From what I read, we can do it using Batch Apex although I am not certain I fully understand how it works. Here ...
Uri Lukach's user avatar
  • 1,264
14 votes
1 answer
11k views

Scheduled Apex, Callouts and Running a Batch

I don't think what I am trying to do can be done with my current setup, but before I embark on some rework, I just wanted to check I haven't missed an approach... I have a scheduled class that ...
BritishBoyinDC's user avatar
14 votes
1 answer
4k views

Schedule and Run a Report as an specific User from Apex

Background What we are trying to accomplish is to run daily some specific reports as an specific user. So far From a lightning component we are allowing the user to select a reports list. Once the ...
Martin Borthiry's user avatar
13 votes
3 answers
87k views

Sample Code to Schedule an Apex class

I'll be working on creating a apex schedule class and I just need a pointer to start is that possible if you can have a working small sample where I can understand how the mechanics work and I have ...
Nick's user avatar
  • 7,012
13 votes
2 answers
16k views

Is it possible to queue a queueable apex job from a scheduled apex job?

I am attempting to implement a piece of scheduled apex which can work in an org with remarkably long computation time, meaning only a few hundred records can be operated on in a single context before ...
user28144's user avatar
  • 167
12 votes
4 answers
51k views

abort currently running job in Salesforce

Is there a way to abort currently running batch job in Salesforce? I tried to run the query below and all it did was remove all jobs from Scheduled Jobs section without stopping the one that is ...
user569925's user avatar
  • 1,179
12 votes
2 answers
17k views

What does the Batch Apex "Holding" status mean and where is it documented?

I've seen the following values in the AsyncApexJob table during the 'cradle to grave' life cycle of a Batch Apex job: BEFORE running: Queued Preparing WHILE running: Processing AFTER running: ...
Matt and Neil's user avatar
12 votes
2 answers
1k views

Poll for long-running API responses - Solution patterns

Many REST APIs that people want to use from within Salesforce have asynchronous, long-running operation. For example An endpoint POST /api/resource to create a resource returning a handle Id to check ...
Robert Sösemann's user avatar
11 votes
2 answers
17k views

Apex cron job command to schedule an apex job to run every 4 hours daily

I have a requirement where i need to run an apex batch job every 4 hours daily monday to friday and all months in a year. I looked at the apex cron job documentation to be setup using code snippets in ...
Buyan Thyagarajan's user avatar
11 votes
5 answers
3k views

Are there best practices to get scheduled apex scheduled to run faster than once per hour?

When trying to set up a schedule to run every 5 minutes I got an error that seemed to indicate that you can't schedule apex to run every X minutes or every Y seconds. It appears the fastest you can go ...
Ryan Elkins's user avatar
  • 7,687
11 votes
1 answer
23k views

How to see full Status Detail of Apex Job

I have an apex job that is failing with a null pointer exception. The status detail unfortunately cuts the stacktrace just short of where it is actually helpful. Is there anyway to view the full ...
NSjonas's user avatar
  • 10.2k
11 votes
1 answer
5k views

Chaining Scheduled Apex to process callouts every 30 seconds

We wanted to create an outbound message queue system that would process requests individually and in order to any external web service. The frequency that these requests should be processed is ...
mdh350's user avatar
  • 113
11 votes
1 answer
2k views

What happens to scheduled jobs set to half past midnight, when the clocks go forward or back?

Trust our team tester to think of this one! When the clocks go forward in Spring there is no time from 00:00 to 01:00. When the clocks go back that time period duplicates. Is Salesforce clever ...
Richard Corfield's user avatar
10 votes
1 answer
11k views

How Many Starttest() and StopTest() can I have in One Test Class?

The concept of testing org is still very new to me. I don't think I fully understand it. But can I've more than one StartTest() and StopTest() in my test class as my test requires many cases to ...
user7123's user avatar
  • 863
10 votes
1 answer
21k views

When do Sessions expire?

I note that Session Settings allows you to have sessions expire as often as low as 15 minutes. However, I believe this is related to browser sessions and sure enough they do time out as expected. ...
Phil Hawthorn's user avatar
10 votes
1 answer
3k views

Does scheduled Apex use synchronous or asynchronous governor limits?

People tend to lump "batch" and "scheduled" Apex together, given that the former is often invoked from the latter. The way they're talked about, it's easy to think that they are both examples of ...
Vivek M. Chawla's user avatar
10 votes
1 answer
973 views

Deploy with Active Jobs - active job ignores deployed code on next scheduled run

I have an anonymous Apex scheduled job that runs every three hours on the hour: String cron = '0 00 07,10,13,16,19,22 * * ? 2015'; MyScheduledDispatcher sd = new MyScheduledDispatcher(); System....
cropredy's user avatar
  • 71.4k
9 votes
2 answers
2k views

What is the maximum length for a scheduled job name?

The question itself is relatively simple. If I call System.schedule(String jobName, String cronExpression, Object schedulableClass), what is the maximum length for a scheduled jobname parameter? ...
Daniel Ballinger's user avatar
9 votes
3 answers
5k views

Schedule apex class to run every minute as there can only be 5 batch jobs

I have a need to execute the Apex class every minute. I have a Sites VF page and in that I have link called "Export to Excel" which exports bulk data (say 50000 records of my wrapper class type) ...
Sathya's user avatar
  • 3,202
9 votes
2 answers
2k views

How can I change an objects record type after a certain time period? Workflow, Apex, other?

I am working on implementing a timed RecordType change in salesforce. I have an object that when created needs to change its RecordType after a certain number of days. The only catch is that if a ...
Chris's user avatar
  • 1,675
9 votes
2 answers
29k views

System.LimitException: Too many queueable jobs added to the queue

I have a scheduler class which is scheduled to run every 5 min which calls a batch class. This batch class calls a method from another class which adds multiple jobs to a queue. When it's scheduled I ...
Abhiram Sheshadri's user avatar
9 votes
1 answer
2k views

Batch Processing Quick Query

I have like 50000 records that meet my condition for batch processing. My batch process begins at say 10:01 AM and ends at 10:10 AM. I set my batch size to be 200. Can someone tell me what would ...
user25311's user avatar
  • 599
9 votes
2 answers
3k views

Apex test class for schedulable class that checks for 5 batches running already

I've setup some chain execution batch classes. For this setup we decided to chain the batch classes through schedulable classes. We thought it might be a good idea to include a check for 5 batch ...
Jomtung's user avatar
  • 376
9 votes
1 answer
2k views

Which timezone are the platform events run with?

What does Salesforce use as the system time when running those jobs? The current system time (UTC)? My context is that I have a job that is run every 30 minutes and it executes a task for some of my ...
Renato Oliveira's user avatar
8 votes
1 answer
9k views

Need System.schedule cron string for run once

Is there a way to use System.schedule to schedule a job that runs only once? I've been looking at the special characters allowed there, and I'm not seeing a way to do it. What I want to do is use ...
Jagular's user avatar
  • 3,356
8 votes
1 answer
6k views

How to delete 10K records in Salesforce via Apex?

This question might be more towards the approach than the technical side. The scenario is the following: I have to run a scheduler to delete some records. The record size is always going to be less ...
subodhbahl's user avatar
  • 1,296
8 votes
3 answers
2k views

System.StringException thrown when aborting a job in a rest controller

This code works in an Execute Anonymous window, but not when run from a rest controller: @RestResource(urlMapping='/scheduler') global with sharing class SchedulerController { @...
edgartheunready's user avatar
8 votes
2 answers
5k views

Too many SOQL rows returned (limit exception) - 50001

I am getting Too many Soql rows returned:50001 (limit exception) on below line of code list<ContentVersion> cvlist= [Select c.Id, c.ContentDocumentId From ContentVersion c ...
sfdc's user avatar
  • 13.7k
8 votes
2 answers
5k views

Deleted scheduled jobs still appearing?

I have a legacy process that has created about 2000 scheduled jobs over 12 months. They are all appearing in the Scheduled Jobs list in the UI. However, when I query the CronTriggers object, I see ...
David Cheng's user avatar
  • 7,084

1
2 3 4 5
19