Questions tagged [scheduled-apex]
Issues with writing, running, or testing scheduled Apex code, using the Schedulable interface.
899
questions
-2
votes
1
answer
20
views
Which is a better approach when updating records using batch class, to place it in execute or finish method?
Sorry but I am new to this and I just wander, do you think it is better to put all the millions of records inside the Map object which is process by the execute method, however the dml where the ...
0
votes
1
answer
26
views
Account deletion job based on object relations
I have a requirement for creating a job for deleting the accounts that do not have related cases, opportunity, Lead.
The 3 objects can also change in future and new object to be checked can be added ...
0
votes
2
answers
65
views
Apex Schedule Job Error - When triggering a Flow
I have created an apex class and executed anonymously a code which forces my flow to run every hour, but I am getting this error
If you use a record variable to update or delete records, the ID value ...
0
votes
1
answer
42
views
Running apex scheduled job automatically getting removed
I have written a scheduled class which will run after every 1 min. From Scheduled Job I am calling a queueable class. Also, for rescheduling after 1 min, I have a platform event which will fire after ...
0
votes
0
answers
61
views
Setting batch size on scheduled apex with batch execute(Database.BatchableContext bc, List<SObject> results)
I have a scheduled batch that I need to adjust the batch size on. I've seen articles where the batch size is managed in the batch class' execute() method, but only when the execute method is in the ...
0
votes
1
answer
51
views
Execute a batch with custom delay between each batch processing
I have a batch class which update the primary field on the quote object using batch size of 1. I need to do this in such a way that each batch is processed 30 seconds after the previous one(there ...
1
vote
1
answer
51
views
Troubleshoot Test Class for Schedulable Apex with Email Message
My schedulable apex is working properly and I have 100% test coverage on it, but the test is not giving me the System Assert I am expecting and I'm hoping someone can spot the reason why.
The Apex ...
0
votes
2
answers
206
views
Is it guaranteed that First submitted Queueable or Batch class will run first?
We have to send case create and update data via API to third party.
For create case: In trigger we are collecting all the case ids in set and calling queueable class if cases created are less than 100 ...
0
votes
0
answers
45
views
How to retrieve a UI Schedule Job metadata from Org?
I know that we can use code to schedule jobs, but I already have a UI based Schedule Job on my org, and I only want to fetch the metadata for that.
I have org browser in my VS Code, but I can't find ...
-2
votes
1
answer
220
views
How to remove permission set from deactivated user using apex
Inactivate users when their last working day is today.
Capture the users last working day in a custom field on user.
Batch will run every day once.
Remove the permission sets assigned to the user ...
3
votes
1
answer
287
views
Interface, System.Schedulable, relationship must be maintained: org deployment error
I am deploying code to 1st generation packaging org. The deployment steps we follow is:
Convert the code base to metadata api format from sfdx format
Execute the command to deploy the code to ...
1
vote
1
answer
177
views
CANNOT_UPDATE_CONVERTED_LEAD Apex Error - Update
I've created a scheduled flow that triggers on the following conditions:
Lead has a related account via a Lookup
Lead Has_Activity__c = True
Lead IsConverted = False
When this is scheduled to ...
0
votes
1
answer
78
views
Unit testing nested asynchronous jobs
I'm trying to make my tests pass but I can't.
I have My Queueable Class:
public class MyQueueable implements Queueable, Database.AllowsCallouts {
public MyQueueable() {}
public static void ...
0
votes
1
answer
104
views
Help-Logic to check if the submitted date/time is after 2PM and skip the update of that record- Batch class
This is the sample batch class that I am working on. This class is working fine but I need to add one more condition like, If status is set to submitted after 2PM, The number field should not be ...
0
votes
1
answer
69
views
Is this a true statement that package upgrade allows to include changes to Schedulable jobs scheduled or in progress?
Usually I ask questions about why something is broken in Salesforce, however, today I want to ask a different question.
We know that we can't deploy unpackaged code which introduces changes into ...
1
vote
0
answers
60
views
How to prevent the parent Queueable Job from having a 'Complete' status until the chained child Queueable job completes?
This is more of a theoretical question.
I have an action button on a VisualForce page which downloads a PDF with large data.
When the action button is clicked, it invokes a Queueable job through the ...
2
votes
1
answer
164
views
Omni Routing Queue Threshold Alert
We use Omni Routing for our live chat and one of the features in there is the Omni Supervisor which shows some metrics on queues such as wait times.
There is a request where leadership in the call ...
3
votes
1
answer
208
views
What is the reason behind the runtime error when Queuable jobs in enqueued?
If a public class implements both Schedulable and Queueable interface
public class A implements Schedulable, Queueable {
public void execute(SchedulableContext c) {
//
}
public ...
3
votes
1
answer
673
views
Is it possible to call a LWC from Apex?
I need to create a PDF document completely customizable and I decided to use an external JS PDF generation lib (PDF-lib) to create the documents from a LWC instead of using the Visualforce PDF method. ...
0
votes
0
answers
181
views
Apex Unit test Database.UpsertResult
I have this following code. The SubId__c is an external and a unique key in FKS_Subs__c object. This object gets data from FKS_Subs_Delta__c object everyday as a scheduled batch job. If it tries to ...
0
votes
1
answer
86
views
Test class for records owned by System User
I have batch job class which fetches ServiceAppointment where Owner.Name = 'System User' in it's Database.QueryLocator start method.
global class CancelDuplicateSaBatchClass implements Database....
0
votes
0
answers
347
views
Test class and code coverage for FSL ServiceAppointment
I have below class for which I am writing test class.
global class FSL_ScheduleSABatch implements Schedulable, Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful {
global ...
-1
votes
1
answer
78
views
Scheduled Apex in waiting for more than a week
I have a couple of scheduled apex jobs which were all running smoothly. But since the beginning of this year pretty much all of them are having CronTrigger state as waiting. Some of them for more than ...
0
votes
0
answers
38
views
InstallHandler Scheduled Apex not Running
I have an installHandler running post install to create a scheduled Apex job that runs a batch Apex operation to an AWS S3 bucket. I am able to run the batch operation and run the scheduler using the ...
0
votes
2
answers
406
views
How to get ID returned from finish method of a batch to LWC?
I have built LWC component to execute a batch job via apex controller.
In the finish method, the batch is returning the id of a record inserted.
I want to display that id on my LWC.
How can I pass the ...
-1
votes
1
answer
62
views
Schedulable single email apex class low coverage when deployed to production
I have a schedulable email apex class that sends email to sales rep with opportunities with awaiting approval as stage. This partial apex class below is 100% covered in production, however when I ...
2
votes
1
answer
34
views
Test Class For Schedulable Apex Without Using (SellAllData=true)
Folks,
I wonder if we have another way to create test class if we don't annotate with (SeeAllData=true).
Here, my SOQL to retrieve a list of ContentDocument have been created more than 7 days. That ...
0
votes
2
answers
524
views
How to schedule the Apex class for every 90 minutes?
I have tried to execute my scheduler class from anonymous window to schedule it every 90 minutes but it is only scheduling for 1 hr.
TokenScheduler testobj = new TokenScheduler();
String ...
-1
votes
1
answer
28
views
Apex Schedule Test Class Code Coverage
How Can I test the below class?
public class SaleItem implements Schedulable {
public void execute(SchedulableContext sc) {
SaleProduct.pollSae('MT');
}
}
-1
votes
1
answer
200
views
How to parse a json having Rows and Columns
I have the below JSON and want to parse it out to get the data. But the JSON format is in Rows and Columns.
{
"returnValue":{
"columnNames":[
"RowID",
...
0
votes
1
answer
340
views
Batch showing zero records processed ,is there a way to throw exception if no Records found in Querylocator
here is batch code which is executing currently showing as zero records processed in AysncApexJob , no errors though ,what i want is whenever batch find Zero record in SOQL of start method then batch ...
0
votes
1
answer
392
views
How to schedule a job twice a day with different minutes?
I have a batch that does three callout and then update some records, if occurs any error in the update or in the callout, a new record in the log object with the IDs of the records that occurred error ...
1
vote
0
answers
110
views
AsyncApexJob.CronTriggerId present but no actual CronTrigger record
Maybe it has always been this way but ...
If you execute System.abortJob(id), the AsyncApexJob.CronTriggerId still retains a value but there's no CronTrigger parent record
Given the following code ...
...
0
votes
1
answer
470
views
How can I call a scheduled method in my LWC?
I want to call a method that I have created, that makes HTTP API callout to and fetches data.
Apex method:
@AuraEnabled(cacheable=true)
public static String events (String webSite, String ...
0
votes
1
answer
345
views
Do Apex Schedules have Metadata?
I'm writing my first scheduled Apex for an internal organization. We do all of our development using sfdx and scratch orgs, merging into production using GitHub actions linked to the main branch.
In ...
-2
votes
1
answer
61
views
Can you please provide test class for this [duplicate]
global class LastLoginEmailJObs implements Schedulable {
global void execute(SchedulableContext SC) {
List<Messaging.SingleEmailMessage> mails = new List<Messaging....
2
votes
1
answer
694
views
How can I make multiple Http callouts in a row?
I need to build an apex class that will perform multiple callouts in a row to an external system and upsert some records.
Right now I'm sending a POST method with a query in the body and getting an ...
-1
votes
1
answer
160
views
Multiple Web Callouts In Scheduled Apex
I'm trying to get some additional information on specific phone numbers in my database using web callouts. I won't hit the governor limits as it's going to be less than 100 numbers per day. I'm also ...
-1
votes
2
answers
144
views
Can we add the debug statement without a method?
I am new to programming world and i have this Doubt
public class new
{
integer h=10;
system.debug(h);
}
this code is not working untill i create a Method and add this debug statement!!!
is it ...
0
votes
1
answer
128
views
Initially My Scheduler class was failing and when I add if(!Test.isRunningTest()) then its passing but its code coverage got dropped to 75%
here is the Apex class:
global class GroupBatchSchedule implements Schedulable {
global void execute(SchedulableContext sc) {
GroupBatch b = new GroupBatch();
if(!Test....
0
votes
1
answer
58
views
Merging two accounts if they have the same website,EIn and phone number
I am working on a batch class to merge two accounts if they have the same website,EIn and phone number.
I did a code and tested with accounts having same EIN same phone number and same website and it ...
0
votes
1
answer
3k
views
I want make test class for batch apex
I want create test class for this batch class and when i execute with this code i got constructor() error.
BatchMessageType myClass = new BatchMessageType();
Id newId = Database.executeBatch(myClass);...
1
vote
0
answers
449
views
Governor Limits: Scheduled Flows vs Async Apex
tl;dr - Do schedule flows (flow builder, not process builder) count against the same limit of scheduleable jobs that asynch apex (Queueable, Scheduleable, Batch) is limited by? If not, in what way to ...
0
votes
0
answers
76
views
How to pass parametrs to scheduled apex class?
I have a method where I need to schedule an apex class that will close several Cases in 5 days but I need to somehow pass Case Id so the scheduled class knows which cases to remove after 5 days. How ...
1
vote
1
answer
382
views
How to differentiate the batch class based on the different parameters passed and fire different email based on the parameters when batch class fails
I have a batch class which performs certain DML operation in execute method based on certain conditions. Also performing an update under finish method. I have a constructor where parameters of type ...
0
votes
0
answers
36
views
test class is not running execute method
thsi is batch class:
global class Batch_ValueEdge_NotifyAID implements Database.Batchable<SObject>, Database.Stateful {
public Integer currentYear = System.Today().year();
global ...
-1
votes
1
answer
430
views
How can I send an email with a salesforce report attached?
I'm try to scheduler email send with a repor attached, but when i received the email, appear the next error in the file:
I'm use the nex Apex code:
global class Exporter implements System.Schedulable ...
0
votes
0
answers
2k
views
Omni-channel: Automated Presence Status change
I've got a requirement which says that an Agent assigned to a Lead must have Presence Status set to 'busy' automatically when the right time comes: 10 minutes before the Date/Time field value in the ...
0
votes
1
answer
115
views
Schedule Apex Class and "Apex CPU time limit exceeded" [duplicate]
This is the first scheduled apex class I've ever attempted, and I keep running into the "Apex CPU time limit exceeded" error. Once a month, I'd like for the system to look for past due ...
0
votes
1
answer
483
views
How to test schedulable class with future callout method
I'm trying to run this test and it keeps failing. The error I'm getting is "System.QueryException: unexpected token: 'null'" so it's related to my lstContacts SOQL query, but I can't figure ...