Questions tagged [asyncapexjob]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
27 votes
1 answer
5k views

Dramatic increase in AsyncApexJob latency

Problem Salesforce is a multi-tenant platform and as a consequence the time for an asynchronous request to be dequeued may vary. This is not a problem for us, as long as the delays stay within ...
Sam Theisens's user avatar
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
10 votes
1 answer
3k views

Can't I use ALL ROWS in asynchronous Salesforce queries?

I would like to perform asynchronous queries that could retrieve deleted rows as well. However, if I submit a batch with SOQL like select Id, IsDeleted, Name from Account where IsDeleted = true and ...
Gabriel C's user avatar
  • 451
8 votes
2 answers
19k views

Call Queueable from future method

I have a use-case where I need to execute some logic in async mode and I found that using Queueable Interface I can achieve that. But when I am trying to the use the Queuable Interface, some issues ...
S.Sharma's user avatar
  • 1,637
8 votes
2 answers
1k views

System.LimitException: Too many async calls created: 2

I am trying to run two batches: 1.ContactNonEligibleMarker - Updates a status on the contact 2.RelationshipCreatorForContact - Creates child records(Relationship__c) under a contact. In the finish ...
Praveen's user avatar
  • 10.1k
8 votes
1 answer
3k views

error from test method - "apex job is already scheduled for execution"

I have a batch apex which starts itself after x mins. this is done in finish() method using , system.scheduleBatch() method. below is how the batch looks like, global class my_ProcessPurge_Batch ...
apn's user avatar
  • 1,722
7 votes
2 answers
13k views

How to delete AsyncApexJob with Queued status

Is there a way to delete an AsyncApexJob with Queued status ? I can't do it in the Setup because I don't have any action link available for this jobs. I can't do it with the purgeOldAsyncJobs() ...
SF_user's user avatar
  • 3,616
7 votes
1 answer
6k views

Check if an SOQL query is valid without actually executing it

I'm building a system where a user will be providing me with a query through a UI. This query will then be used in an Async Apex Job, by passing it as a param to Database.getQueryLocator in the start ...
coldspeed's user avatar
  • 701
7 votes
1 answer
457 views

Is an AsyncApexJob record inserted immediately at the end of a transaction?

Is an AsyncApexJob record inserted immediately at the end of a transaction or is it possible that there is a delay between those two events? I couldn't find firm guarantee in the documentation on that....
ipavlic's user avatar
  • 3,694
6 votes
1 answer
2k views

Testing Recursive Queueable Class

I have an Apex class that implements the Queueable interface which is used to remove custom objects attached to a set of Account Ids, and then inserts new custom objects to replace them. The volume ...
doublesharp's user avatar
6 votes
1 answer
590 views

ApexTestRunResult's status is set to complete and all tests pass, but the enqueued and completed count do not match

It is possible to programatically run tests in the platform by creating ApexTestQueueItem records. They reference classes by their Id, and you can even optionally specify if you want the test to ...
Renato Oliveira's user avatar
6 votes
1 answer
6k views

Can't Save Class (batch or future jobs pending or in progress)

I have a problem saving one of my classes into server. The error that I get is: Error: Compile Error: This Apex class has batch or future jobs pending or in progress at line -1 column -1 I have ...
ashkanent's user avatar
  • 335
5 votes
1 answer
346 views

AsyncApexJob table has additional record initially? platform bug?

I noticed when creating a new dev org, and running my first batch job. I then query the AsyncApexJob table and there are 2 records instead of the expected 1. There seems to be a default record in ...
nickforce's user avatar
  • 417
5 votes
1 answer
294 views

Can't find Apex Jobs that are blocking deployment

I am trying to delete a couple of old unused Apex Classes in our Production. Every time I try to delete all or one of them I get the following error message: "This apex class is referenced ...
Florian's user avatar
  • 53
4 votes
2 answers
1k views

How to avoid running a batchable when an instance is already running?

We have several batchables that if run in parallel trample over each other's results. So I want to block a second invocation if there is already one running and just tell the user to wait. My first ...
Keith C's user avatar
  • 136k
4 votes
2 answers
5k views

What's the difference between AsyncApexJob and CronTrigger?

Roughly I know that when I schedule a Schedulable, I'm creating both a CronTrigger and an AsyncApexJob, but I'm confused as to how the two objects relate to each other and what the significance of ...
user823447's user avatar
4 votes
1 answer
7k views

How can I tell batch job finished executing the finish() method?

In my controller I want to know when my batch job has fully finished running; not just the execute method but also the finish. I have tried the following and both seem to return true when execute has ...
Mossi's user avatar
  • 3,956
4 votes
1 answer
2k views

Testing the ACTUAL batchable context in Database.Batchable methods?

I'm trying to mock Database.BatchableContext to make my unit tests more robust and to eliminate excess usage of Test.isRunningTest() running in production code. Few hacks are available like Json....
Matt and Neil's user avatar
4 votes
1 answer
361 views

Are start() methods of batches guaranteed to run sequentially?

The question is very similiar to this one: Are batch jobs guaranteed to run sequentially? I basically want to ask the same thing, except this time for start() method. Do start() methods of ...
Kamil Pilarski's user avatar
4 votes
1 answer
500 views

Is apex:actionPoller asynchronous?

I have an action poller in my controller and I want check for a batch process if it is completed or not? I am querrying the Batch process to check if completed. I am not sure if this is async or sync ...
akash's user avatar
  • 937
4 votes
0 answers
614 views

AsyncApexJob: TotalJobItems != JobItemsProcessed + NumberOfErrors

I'm running into an odd issue where AsyncApexJobs (from Batch Apex) are finishing with a status of "Complete" but the TotalJobItems != JobItemsProcessed + NumberOfErrors. Should I be concerned that ...
NSjonas's user avatar
  • 10.2k
3 votes
2 answers
4k views

Why should we use Queueable apex when we can perform chaining of batches in batch apex (when we can call another batch in the finish method)

We can call another batch from the finish method of one batch, then why do we need Queueable apex
paritosh parimal's user avatar
3 votes
2 answers
11k views

Retrieve a list of currently running jobs

I'm building a system that will be calling executeBatch on quite a few batch apex jobs. I want to make sure that I haven't already hit the limit on the max number of jobs queued up. I believe ...
coldspeed's user avatar
  • 701
3 votes
2 answers
5k views

Why salesforce has introduced Queueable Apex. need some proper clarification

future method behaviour - 1. is executed in their own thread 2. do not start untill resource are available 3. future callout gives us 200 asynchronous soql limit. Why we use Queueable Apex and in ...
Nirmallya Ghosh's user avatar
3 votes
3 answers
9k views

How to capture Queueable class status when job is completed

I have created Queueable class to process data and making the callouts this Queueable class executes upon after update and after insert of Opportunity object. Now in order to track the status of ...
Hunt's user avatar
  • 245
3 votes
0 answers
148 views

schedule jobs to be run in the past

I have a scheduled job whose "Next Scheduled Run" is set to a date in the past: Cron expression: 0 30 20 * * ? * Does it mean that this scheduled job will never run? What could be the reason for ...
Cuban coffee's user avatar
  • 1,554
3 votes
0 answers
896 views

Queueable interface to chain Apex batch jobs

Can we use the Apex Queueable interface to chain batch jobs? I am planning to invoke a Apex Queueable interface from the finish method of a batch job. The Queueable interface would queue the Apex ...
nonce's user avatar
  • 85
2 votes
3 answers
1k views

Why queuable apex accepts sobjects where as future methods doesn't?

I was going through asynchronous apex and reading it made me confused at one point. In future methods, we cannot pass sojects for reasons future methods being executed at a later point of time, by the ...
Jayakrishnan Salim's user avatar
2 votes
1 answer
3k views

Getting class name from BatchJob?

i have tried AsyncApexJob to get class name which is being executed in that job...but unable to get it.. i need help on this thanks
Krishna Bidwai's user avatar
2 votes
1 answer
522 views

Method not getting called after addError, Please advise

I am new to SFDC please help. Requirement: Restrict user deactivation if Account is owned by the user and send an Email with details. Trigger on user object: trigger userTrigger on User (before ...
Alpha1331's user avatar
2 votes
2 answers
5k views

Get the scheduled Job name using Apex class name

I have seen many posts about finding out name of the apex class associated with a scheduled job. However, i have an opposite need. I am updating a scheduled class, that was scheduled to run at a ...
user2957592's user avatar
2 votes
1 answer
742 views

Governor limits in dispatching BatchApex jobs - how much and where to find them?

As a follow up to this question, here are some questions I've not been able to find an answer for: How many batch jobs can you dispatch before you exceed governor limits? 100 or 105? Do scheduled ...
coldspeed's user avatar
  • 701
2 votes
1 answer
34 views

How do I expose background tasks to end users?

My users sometimes kick off some long-running background processes (e.g., add 150 records that look like this template, run this batch process, etc.). Right now, if those processes fail, they are not ...
Charles Koppelman's user avatar
2 votes
0 answers
83 views

Apex Engine old Version of apex code changed?

Recently (since January) we have encountered some cases when deploying new versions of our managed package. We have had at least 2 separate instances where changing a batch or an apex class referenced ...
Jose's user avatar
  • 2,142
2 votes
0 answers
453 views

Iterable in apex batch start

Iterable had an upper limit of 10000 records in batch apex earlier, when used as return type for start method. However in docs, I cant seem to find it anymore. Is this limit removed or not relevant? ...
Amit's user avatar
  • 344
2 votes
0 answers
979 views

All attempts to execute message failed, message was put on dead message queue

I have a process that is chaining Queuables using a future method similar to this: public class MyQueuable implements Queueable{ public virtual void execute(QueueableContext context){ //do ...
NSjonas's user avatar
  • 10.2k
2 votes
0 answers
288 views

When does System.abortJob() take effect with regards to a transaction?

If I call System.abortJob() in a transaction, when is the job actually aborted? Does it happen immediately, or only once the transaction is committed? I suspect the latter, as you don't want to have ...
Daniel Ballinger's user avatar
2 votes
0 answers
1k views

How to get the info on AsynCallouts made with Continuation framework(or Class)

I am using WSDL classes generated from the WSDL xml, to make the webservice callouts. I was making the callout synchronously, but later I want to change it to Asynchronous callouts. As we already know ...
Azeez's user avatar
  • 103
2 votes
0 answers
2k views

Apex Batch job is failing with Internal Salesforce Error

I have a batch job that i'm executing from developer console Id batchJobId = Database.executeBatch(new TPI_BATCH_CHILD_ACCOUNT_PUSH(), 200); But i've checked from workbench with the batchjob id its ...
user59759's user avatar
  • 581
2 votes
0 answers
492 views

purgeOldAsyncJobs(dt) does not delete old aborted ScheduledJobs

I have a process that create scheduledjobs every minute (someone else wrote it). It is scheduled every day at 8 then schedule itself until 20. I know Salesforce should delete jobs older than 7 days ...
Guillaume's user avatar
  • 115
2 votes
0 answers
80 views

Queueable vs Schedulable vs Batch Apex? [duplicate]

Could somebody please clarify on which one to use under what conditions? Apologies for asking question at a very broad level but I just want to know from people who handles large data, what is the ...
kumar's user avatar
  • 43
1 vote
3 answers
2k views

Getting the job id of a chained job from the id of the parent job

I have a Queueable job that will initiate a Batch job. I have a transaction that enqueues the Queueable job and returns the id of the Queueable job. However, I need to be able to get the id of the ...
Jorjani's user avatar
  • 2,212
1 vote
1 answer
2k views

What user is queueable apex class running as?

I have a queueable class, that is executed correctly (and working asynchronosly calling external services) I have an issue, that within the class, the following line: system.UserInfo.getUserEmail() ...
Saariko's user avatar
  • 5,610
1 vote
1 answer
398 views

How can I save a class when a batch job is running (without the Ant tool)

I am trying to figure out if we can save a class which is used in a batch job. I am unable to save a class. I can't save the class when a batch job is running. I don't want to abort the job. Is there ...
Malik's user avatar
  • 31
1 vote
1 answer
3k views

How is calculated "24-hour period" for the limitation of Asynchronous Apex Executions

I have a question regarding Execution Governors and Limits for daily maximum number of asynchronous Apex method executions. In the Salesforce documantation it is written, that the maximum number of ...
R.Paunova's user avatar
1 vote
1 answer
1k views

Can a future method conflict with a queuable method?

My custom code is executed using a queuable class. Sometime it runs perfectly, other times it gives this error: Failed to update list. Error: System.DmlException: Update failed. First exception ...
user2278489's user avatar
1 vote
1 answer
1k views

AsyncApexJob returning two records for one executed instance of batch

When I am executing one batch then that batch runs only once. I have verified it from the 'Apex Jobs' from Setup. But when I am querying the AsyncApexJob for that batch class, it is returning two ...
Muskan Agarwal's user avatar
1 vote
1 answer
415 views

I am trying to Schedule Class that will add a new contact under Account every 2 min

I am trying to Schedule Class that will add a new contact under All Account every 2 min and also there should be a validation check that you can not have more than 05 Contacts under a single Account. ...
Dave's user avatar
  • 480
1 vote
1 answer
314 views

AsyncApexJob record when I use System.scheduleBatch() method

I have just found a very strange behavior regarding Batch. If I have a Batch and run it using the method Database.executeBatch(), a new record inside AsyncApexJob table is created and I can use ...
vt89's user avatar
  • 721
1 vote
1 answer
1k views

Rollback all completed jobs in a chain

I'm writing an application where I'm chaining jobs by calling executeBatch for the next job in the finish method of the previous one. In case a job somewhere in the chain fails, I'd need to rollback ...
coldspeed's user avatar
  • 701