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
Chandradeep MishraChandradeep Mishra 

Apex Batch with Custom objects & Apex Queuable with Custom object

Hi,

any example with Apex Batch with Custom objects & Apex Queuable with Custom object. where you can show iteration on object of custom and update/insert some values.
ShirishaShirisha (Salesforce Developers) 
Hi Chandradeep,

Greetings!

Please find the example on Account Object and you can replace it with anyone of the custom Objects as per your requirement.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Chandradeep MishraChandradeep Mishra
No, It is not working using the article yet.
ShirishaShirisha (Salesforce Developers) 
Hi,

Can you please provide the error message if you have any while trying this.So that,we can try to fix the issue based on that.

Thank you!
Chandradeep MishraChandradeep Mishra
User-added image
Hi Shirlsha,

This is the code which is simple verson of mine and it is not giving any such error but fail to execute 100% and stopped or not execute the bold code where I want the access the list and you can see in test screen it marked it as red :

global class TriggerMyJob implements Database.Batchable<Sobject>
{
 
    global Database.QueryLocator start(Database.batchableContext bc)   
    {   
        Integer count = Limits.getLimitQueryRows() - Limits.getQueryRows();
        System.debug('---result 1 ' + count );
        string query = 'SELECT Id, Academy_User_FullName__c, Academy_User_CompanyName__c, Academy_User_job_title__c, Academy_User_Profession__c, Academy_User_IndustryAcademy_User_Indust__c , Webinar_Name__c, Registrations__c FROM EnrollmentCPA__c';
        system.debug(Database.getQueryLocator(query));
        //add code to display the result.
        Database.QueryLocator q = Database.getQueryLocator([SELECT Id, Academy_User_FullName__c, Academy_User_CompanyName__c, Academy_User_job_title__c, Academy_User_Profession__c, Academy_User_IndustryAcademy_User_Indust__c , Webinar_Name__c, Registrations__c FROM EnrollmentCPA__c]);
        // Get an iterator
        Database.QueryLocatorIterator it =  q.iterator();
        return q;
 }  
    
    global void execute(Database.batchableContext info, List<EnrollmentCPA__c> scope)    
    {
      System.debug('tsting' + scope);
    }

    
    global void finish(Database.BatchableContext bc){   }    
}
Following is hte screen