Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 887

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

3 votes

not getting output for schedulable batch class

I don't see anything wrong with the email sending code. But it looks like you are not calling Database.executeBatch anywhere so the batch will never run. Personally, I would just use the "Schedule Ape …
Keith C's user avatar
  • 137k
2 votes

Compile Error: Variable does not exist: loginstring at line 49 column 42

Do not assume that an error reported at a line number implies that all the preceding lines of code are error free. The Apex compiler is not as optimised as some compilers in how it reports errors. In …
Keith C's user avatar
  • 137k
2 votes

DML statement found null SObject at position 0

When DML (data modification) is being done you have a null value in the list which is not allowed. The most likely place this is coming from is when cr is left null because Request_Type__c matches ne …
Keith C's user avatar
  • 137k
3 votes

Need help with Apex Batch job

Assuming the number of deletes is not massive, the Database.Stateful approach is a good one. Store in a property the information from the execute method you want to email and email that information in …
Keith C's user avatar
  • 137k
2 votes
Accepted

Best practices for schedulable class

Personally I would not add an extra field but rather query to find the Lease_Reminder objects to update i.e. match on the date and on the wrong status so you only update the status values you need to. …
Keith C's user avatar
  • 137k
4 votes
Accepted

Apex batch getting an error out

Database.Batchable nominally supports parameterised types (using the <> notation) but it appears that when returning Database.QueryLocator rather Iterable from the start method you have to stick to <S …
Keith C's user avatar
  • 137k
0 votes

SOQL to query parent to child

Adding this term to the end of your BMCServiceDesk__Incident__c query AND Id not in ( select Id from BMCServiceDesk__Task__c where BMCServiceDesk__FKStatus__c != 'Resolved' ) would logi …
Keith C's user avatar
  • 137k
0 votes

Need help-apex cpu time limit exceeded

I'd go with running restructuring your code into a batchable where you start the batchable from the execute method of the schedulable. (This is Adrian's second suggestion clarified a bit.) This way yo …
Keith C's user avatar
  • 137k
2 votes
Accepted

Render Email with batch

Here is a template to get you started (if you choose to go the Apex code way): public class YourClass implements Database.Batchable<SObject>, Database.Stateful, Schedulable { …
Keith C's user avatar
  • 137k
2 votes
Accepted

Testing scheduled apex, Class variables seem to change after test

I've experienced this kind of problem and my understanding is that that a copy (clone) of the objects that are scheduled (vm and vct in your case) is made and so the code executes on the copy not the …
Keith C's user avatar
  • 137k
0 votes
Accepted

Batch Apex for Counting number of Contacts associated with Account

Here is a simple way to wrap this up in a Batchable. All the Batchable mechanism is being used for is to divide up the Accounts into blocks. public class MyBatchable implements Database.Batchable<SOb …
Keith C's user avatar
  • 137k
8 votes

How can I change an objects record type after a certain time period? Workflow, Apex, other?

To accomplish a number of date-dependent pieces of work we run a Scheduled Job - a class that implements Schedulable - every night. That job can then kick-off a chain of classes that implement Databa …
Keith C's user avatar
  • 137k
3 votes

Scheduled Batch runs successfully but Emails are not being Sent

This (present in the execute method) is 99% of the time a bad thing to do: try { // Some code goes here } catch(Exception ex) { } because it is catching and throwing away information ab …
Keith C's user avatar
  • 137k
1 vote

Scheduled job threw unhandled exception

An exception being thrown means any code after that exception is thrown is not run and normally also means that any database changes will be thrown away (the transaction will be rolled back). So some …
Keith C's user avatar
  • 137k
1 vote

Null pointer Exception on apex batch Salesforce

I recollect that email messages are not serializable which may be why transient has been added. So instead create your own class (can be a nested class of NotifyBatch2) that has the required attribut …
Keith C's user avatar
  • 137k

15 30 50 per page