Questions tagged [scheduled-apex]

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

Filter by
Sorted by
Tagged with
41
votes
4answers
20k 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 ...
55
votes
5answers
64k 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.
36
votes
2answers
4k 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 ...
63
votes
1answer
4k 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 ...
35
votes
3answers
8k 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 ...
14
votes
1answer
14k 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 ...
25
votes
5answers
28k 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 ...
7
votes
4answers
6k 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 ...
17
votes
3answers
15k 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? ...
25
votes
6answers
9k 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 ...
25
votes
1answer
17k 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 ...
13
votes
2answers
20k 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,...
97
votes
0answers
3k 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 ...
24
votes
2answers
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 ...
12
votes
5answers
15k 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. ...
10
votes
1answer
2k 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 ...
9
votes
1answer
1k 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 ...
10
votes
2answers
10k 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 ...
11
votes
2answers
2k 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....
5
votes
2answers
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> ...
14
votes
3answers
19k 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 ...
9
votes
1answer
4k 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 ...
7
votes
3answers
4k 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) ...
12
votes
3answers
38k 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 ...
27
votes
3answers
17k 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 ...
7
votes
1answer
719 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 ...
7
votes
1answer
6k 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(...
4
votes
2answers
4k 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, ...
13
votes
2answers
24k 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 ...
10
votes
1answer
18k 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. ...
8
votes
1answer
2k 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 ...
7
votes
3answers
4k views

Scheduled batch “already scheduled”

I had a batch job that I tried to start. Its "startup" method that launches it checks to see if it's already running by querying the asyncjob object, then starts it only if it's not running already ...
5
votes
3answers
11k 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 ...
3
votes
1answer
6k 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. ...
3
votes
1answer
3k 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 ...
2
votes
1answer
2k 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 ...
11
votes
5answers
2k 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 ...
7
votes
1answer
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 ...
5
votes
2answers
9k 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(...
5
votes
3answers
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 ...
4
votes
1answer
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 ...
4
votes
2answers
2k 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 ?'; ...
3
votes
2answers
3k 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 ...
0
votes
1answer
132 views

I am not get the tabular report body in the attached email [closed]

I am not get the tabular report body in the attached email ,could you please help me. global class Exportertest implements Schedulable,Database.AllowsCallouts{ global void execute(...
0
votes
2answers
2k views

How to send Weekly Email to email-fields of records?

I have rejected Workflow Rules, since email alerts can't be sent at the exact same time every week. I have rejected schedulable Reports/Dashboards since emails can't be sent to email fields of records ...
21
votes
3answers
38k 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.
6
votes
1answer
5k 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 ...
13
votes
1answer
8k 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 ...
32
votes
2answers
8k 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?
1
vote
2answers
91 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 ...