Questions tagged [scheduled-apex]

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

Filter by
Sorted by
Tagged with
-2 votes
1 answer
39 views

Advantages of Scheduling through Apex than compared to the UI [closed]

I'm exploring the options for scheduling tasks within Salesforce, and I'm particularly interested in understanding the benefits of utilizing Apex for scheduling compared to using the built-in UI ...
6 votes
4 answers
24k views

Can't save apex class, schedulable jobs pending

When I edit and try to save an Apex class, I get the following message: Compile Error: This schedulable class has jobs pending or in progress at line 11 column 8 How can I fix this?
0 votes
0 answers
27 views

What could cause a apex scheduled batch class to run but not update records even when unit tests have passed?

I spent hours troubleshooting my batch class but I cannot get it to update records. The ask is if a Opportunity closeDate >15th of the month, and CareStatus__c = 'ADM','AAMT' than ...
0 votes
0 answers
31 views

Code Coverage issue for my scheduled class [duplicate]

In have been written a schedule apex class to send an email to users where the opportunity not modified by 14 days, the class is working fine I am writing the test class which it is not covering the ...
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 ...
0 votes
1 answer
33 views

CSV report generation using apex batch

I am trying to generate the csv report by fetching the data from ApexTestResult obj. But the column 'message' in the apextestresult obj is overlapping and automatically divided the message and showing ...
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....
3 votes
2 answers
361 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 ...
0 votes
1 answer
858 views

Test Class Coverage for Scheduled and Batch Classes

I am attempting to test a scheduled class that calls a batch class to update records. The following test class does not seem to find the Opportunity being created in the test class to pass that list ...
0 votes
2 answers
45 views

Test Class coverage on execute method of Batch Apex which is Scheduled to run at specific interval of time

I have a Batch class, which queries Lead records that were created 1 day before. I have created a custom Label 'More_Than_1_days' which has the value 1. I was using this custom label in that batch ...
5 votes
1 answer
1k views

Emails are not being received when sent through Apex

Below is my sendEmail Method . public void sendMail(List<user> Users, string emailTemplateName) { final string FROM_ADDRESS ='Test'; List<Messaging.SingleEmailMessage> emails = new ...
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 ...
5 votes
1 answer
1k views

question on crontrigger and possible state values

Whenever a scheduled Apex Job is submitted, an entry is made in the CronTrigger table. What I see is, when this job is completed successfully, I see the State changed to "DELETED". Based on the SOAP ...
1 vote
1 answer
1k views

Change Email Language, Not Based On Running User's Language

I created a scheduled job which sends an email to System Administrator everyday. The scheduled job works in English and Japanese. I created a custom label and used translation workbench to translate ...
0 votes
1 answer
139 views

Is there a way to schedule a flow to run three times in a day?

I wrote an Apex class and I have used that class in Schedule-Triggered Flow, and I want to schedule it to run thrice a day. While searching about I found that I have to create a Schedule-Triggered ...
-1 votes
1 answer
55 views

Can't find the apex class in scheduled apex [duplicate]

how to find the apex class in this scheduled apex record.its not showing the apex class , then I try this in apex jobs section but it's also not showing. Please give me solution for that . How do I ...
2 votes
2 answers
2k views

Calling Flows from Batch Apex and making the Flow.Interview Class Bulkified

I am running a scheduled batch job daily on 25,000 records and growing. I Want to be able to leverage Salesforce Flow for processing the data because it gives more control to the Admin for ...
-1 votes
1 answer
79 views

How to create different kind of scheduled apex jobs [closed]

How to create the following apex jobs(Types) Reporting Notification Sitemap SEO Generation Job Sitemap SEO Incremental Job Can you explain these apex job types and how to create these jobs in ...
1 vote
0 answers
41 views

Triggering Scheduled Job During Unlocked Package Installation/Upgrade

Within our unlocked package, we have implemented a class TimesheetWindowScheduler that implements the Schedulable interface. This class is responsible for executing specific tasks. public with sharing ...
7 votes
2 answers
4k views

New Apex Batch Jobs always end up in the flex queue in holding

I've noticed some strange behaviour in an org which I've not seen before regarding Apex Jobs. It seems all batch jobs, which are started by a scheduled apex job, never run straight away and are ...
-2 votes
1 answer
388 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 ...
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 ...
0 votes
1 answer
30 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 ...
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 ...
0 votes
2 answers
112 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
54 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
423 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
126 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 ...
0 votes
2 answers
2k views

code coverage 0%

I got an error in the inbound change sets in my production mode and found out that my code coverage is 0%. I created an Apex Class over in a sanbox and I need to get the code coverage to reach 75% but ...
1 vote
1 answer
129 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 ...
1 vote
3 answers
3k views

Run a schedule class every 1st of the month leaving weekends

I want to run a schedule class every 1st date of the month but if it is a saturday or a sunday I want to execute it on the coming monday.I have created a CRON expression that helps it to execute on ...
0 votes
2 answers
353 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
74 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 ...
3 votes
1 answer
327 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 ...
-2 votes
1 answer
444 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 ...
1 vote
1 answer
574 views

Apex scheduler - execution may be delayed based on service availability

According to Salesforce's documentation: "Salesforce schedules the class for execution at the specified time. Actual execution may be delayed based on service availability." When is the service not ...
1 vote
1 answer
355 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
110 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
128 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
91 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
81 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
705 views

How to generate AWS cloudfront signed url in apex?

I am trying to generate AWS Cloudfront signed url using apex but every time get Access Denied. public url is working fine. i.e. jueh890044563.cloudfront.net/test.pdf But I need a signed url of ...
2 votes
1 answer
250 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 ...
5 votes
3 answers
5k views

Unable to find schedule job for apex class

I have one apex schedulable class. I am trying trying to search class in All Scheduled Jobs,but I don't know the name of job for that particular apex class. How should I find the job name for that ...
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,...
3 votes
1 answer
1k 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
234 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 ...
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 ...
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 ...
0 votes
1 answer
137 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....

1
2 3 4 5
19