Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [scheduled-apex]

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

Filter by
Sorted by
Tagged with
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
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
63 votes
6 answers
97k 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
39 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
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
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
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
7 votes
4 answers
8k views

SessionID problem in Schedule Batch class

I have my below batch code and i need to schedule it daily at 12.00 AM. The batch runs but nothing gets done due to the session ID problem. How to solve this problem. public class updateCurrencyBatch ...
sunny's user avatar
  • 1,387
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
21 votes
3 answers
52k 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
79k 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
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
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
  • 494k
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
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
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
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
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
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
7 votes
1 answer
2k views

Permissions to execute System.abortJob() method

What permissions does user need to call System.abortJob() in Apex? When the method is called this error is displayed: System.SecurityException: Insufficient Privileges. Thanks.
Airton Gessner's user avatar
3 votes
2 answers
2k views

Avoid Lock Row exception in Batch Processing

I have a Batch on Lead that is scheduled to run every 5 minutes. The criteria to pick the record in Batch is a field on lead ex. Flag = True. let's say very first-time batch runs and there are 50k ...
Sarvesh's user avatar
  • 998
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
7 votes
3 answers
12k views

Salesforce: Is there any way to set System time in test class

So I have a trigger and a schedule class. The trigger will fire upon update on an object and schedule a job which will execute the scheduled class. There is some logic in the trigger related to non-...
user3088377's user avatar
5 votes
2 answers
13k views

how to pass value from visual force page (InputField) to controller?

I have created a Vf page from which i need to fetch the value of new owner and need to save the value in property defined in controller: Following is my vf page code: <apex:pageBlockSection> ...
jack's user avatar
  • 61
1 vote
1 answer
2k views

Batch Apex Too many SOQL queries: 201

I am getting Batch Apex Too many SOQL queries: 201 when the class is scheduled for run in developer console. Batch Apex: global class Batch_EmailBlast implements Schedulable,Database.Batchable<...
Serena's user avatar
  • 33
0 votes
2 answers
3k views

Test class for Schedulable class

I have the following class which implements the 'schedulable' interface and need help to write a test class to complete the code coverage please: the class checks if the campaign start date is ...
Prabhu Sethupathy's user avatar
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
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
13 votes
3 answers
88k 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,022
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
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
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
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,232
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
7 votes
1 answer
7k views

Is anyone using classes in anonymous apex?

I can't find anyone writing about this, but this works when executed anonymously: public class foo { public void bar() { system.debug('\n\n#### FOO BAR ####\n\n'); } } foo f = new foo(...
twamley's user avatar
  • 785
7 votes
1 answer
3k views

Salesforce timezone issue

Hi guys we have a problem with DST (Daylight Saving time) We show the time in a Visual Force interface according to the time zone of the logged in user. However in the Salesforce objects we are ...
Malaka Silva's user avatar
6 votes
3 answers
19k views

Scheduling a Batch job at a particular time

I have a Apex batch class which I would like to schedule at a particular date time. The date time is stored in a variable and changes dynamically. ex Datatime scduleDateTime = datetime.now() ; I want ...
SfdcBat's user avatar
  • 4,811
6 votes
1 answer
9k views

Governor limits in scheduling ScheduledApex jobs - how much and where to find them?

I've been working with Salesforce for over a month now, and in this short time I've learned a lot about the platform. In the process, I've come across situations where the following questions have ...
coldspeed's user avatar
  • 701
5 votes
3 answers
2k views

How to find/stop/disable Apex Jobs that a read-only user has activated

As a followup to this question, Contact last-modified date changed by read-only user - it appears that the source of the issue might be that a read-only user some how activated APEX batch jobs that ...
blunders's user avatar
  • 1,618
5 votes
2 answers
10k views

How to write test class for Schedulable class [closed]

global class ScheduleBatch implements Schedulable { global void execute(SchedulableContext sc) { BatchArticleUpdateCase batch = new BatchArticleUpdateCase(); database.executebatch(...
user4702942's user avatar
4 votes
2 answers
3k views

Setting up a schedule task

I have set up a schedule task as per instructions here: To turn the scheduling on, I open a dev console and do: MY_NS.MyScheduleTask = new MY_NS.MyScheduleTask (); String sch = '35 27 15 1 3 ?'; ...
dublintech's user avatar
  • 4,263
4 votes
2 answers
11k views

Case Report grouped by Hour of Day

I need to create a report that shows the Case high traffic trends for each hour of the day for the current year. Basically, the customer wants to see a report for the current year of cases opened, ...
Chris Duncombe's user avatar
4 votes
1 answer
3k views

Does Test.stopTest() cause ALL waiting asynchronous functions to fire?

For practice, I'm composing on a unit test for a Schedulable class: /** * Example of scheduling Apex Batch Processing * @see Apex Workbook, page 68 **/ global class WARE_CleanMerchandiseScheduler ...
Brian Kessler's user avatar
3 votes
1 answer
9k views

Too many query rows: 50001

I am getting Too many query rows: 50001 when i run the batch apex. Below code is part of batch apex (FInish Method). Also there is a soql inside for loop .can someone help me fixing this. ...
sfdc's user avatar
  • 13.7k
3 votes
2 answers
4k views

Are Process Builder workflow rules more likely to violate CPU Time limts than a standard/old workflow rules?

I think so and I'm wondering if others have seen similar issues. Our org has nightly job, very simple code, just updates Contact records if it meets simple criteria. It's been running for months ...
StartingAgain's user avatar
3 votes
1 answer
2k views

How's This for a Simple HTTP Callout Retry Framework?

Most of what I have read about retry operations is that they are vaguely complicated and indepth. I have written the code below which seems to accomplish this without too much confusion - I'm ...
number41's user avatar
  • 958
2 votes
2 answers
1k views

Schedulable - Apex CPU time limit exceeded

We have this nightly code that runs in our org. Recently, we started receiving APEX CPU Time limit exceeded errors and we're looking for ways top optimize the code. Anyone have any suggestions on ...
StartingAgain's user avatar
2 votes
1 answer
3k views

Apex Batch Job Chaining Limits

What is the stack depth for apex batch job chaining? I am conditionally calling the same batch job from the finish method.. Also the solution implemented calls a normal batch job from the finish ...
nonce's user avatar
  • 85