function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Giddamreddi ReddyGiddamreddi Reddy 

questions 123

give me  Replay for this Questions  
1.we can write Batch class schedule class  at a time in same class..? 
2. How many number of External Id records displaying for page?
​ 3.what is advantage of limitations,why we use?
Chandra Prakash PandeyChandra Prakash Pandey
1. Yes, It's Doable but just in a different way where rather than having two different nature classes in one, we can have only one class for both the tasks. Just have a look:
global class Demo_Batch_With_Schedular implements Schedulable, Database.Batchable<sObject>
{
    global void execute(SchedulableContext SC)
    {
        Demo_Batch_With_Schedular batchProcessObj = new Demo_Batch_With_Schedular();
        Database.executebatch(batchProcessObj, 1);
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        String query = 'SOQL Query To Select Records that will be processed by batch';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<sObject> objList)
    {
        //Batch code to perform some activity on selected records...     
    }

    global void finish(Database.BatchableContext BC)
    {
       //Batch code to perform anything when batch execution finishes...
    }
}
If you see above code snippet, our  Demo_Batch_With_Schedular class is implementing Schedulable and Batchable both the interfaces, so you can schedule this class and inside that one you can call your batch also.

2. To me, this question is not clear.

3. Refer this: https://developer.salesforce.com/page/Governors_in_Apex_Code
This link explains what are SFDC governor limits and why are they there.

According to me, these limits are really helpful that allows you to think out of the box where you use your creativity or logic to accomplish the same thing without hitting any limits. I know they irritate you if you are hitting them and have no solution to get out of it.

All in all, by limits you are on the way to improve your coding and code design.