Create a new apex class implementing the schedulable interface
In the execute method, simply execute the batch class.
Navigate to Setup -> Apex Classes -> Schedule. You will now be able to select the schedulable class which in turn executes the batch.
In the execute method, simply execute the batch class.
Navigate to Setup -> Apex Classes -> Schedule. You will now be able to select the schedulable class which in turn executes the batch.
What are Named Credentials?
Named Credentials is a secure way to store external application credentials (username/password or secure tokens) when you make a callout to an external system from apex.Create a named credential as below.We just create a username password credential, but keep in mind that named credentials support a variety of options including oAuth, AWS etc.
Recursion happens when code execution falls in a loop and keeps executing indefinitely. You get a run time exception 'maximum trigger depth exceeded'
To avoid such situations we use a static variable. Below is a simple example. In the code below the trigger fires on after update and updates the lead one more time. But, we want to run this for one time only. Setting the static boolean flag avoids executing the trigger the second time. Static variables live throughout the entire apex transaction and hence their value remains intact. Try removing the static keyword to get into the exception.
Execute the following two blocks of code separately from the developer console. The system will create two jobs, one which runs every 0th minute (1PM 2PM 3PM etc) and one which runs every 30th minute (1:30PM 2:30PM 3:30PM etc)
ClassName gp = new ClassName();
String cronStr = '0 0 * * * ?';
System.schedule('Job which runs at every 0th minute of hour', cronStr, gp);
ClassName gp = new ClassName();
String cronStr = '0 30 * * * ?';
System.schedule('Job which runs at every 30th minute of hour', cronStr, gp);
Problem:
You get this exception message on a simple aggregate query like this.Select Status from Case GROUP BY Status - FAILS
You try to use a limit clause but the query still fails.
Select Status from Case GROUP BY Status LIMIT 1000 - STILL FAILS
Reason:
Even though you may use a limit clause, aggregate queries will have to touch all records in the database. If you have less than 50000 Cases you would not receive this error message.Solution:
Couple of probable solutions.- Try to limit query results using a WHERE clause.
- If using this on a visualforce page and you do not perform any DML (insert, update etc) from the page, set readOnly=true on the apex:page tag.
- If using this on a visualforce page and you need to perform DML operations, use @RemoteAction and @ReadOnly on your apex class and deal with the results using javascript. Example link.

