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
Adam BinderAdam Binder 

Help needed building Apeex code to update all records


I have no experience with Apex classes and need help building one...

I have a custom object called Orders_and_Invoices__c
I have processes built in the process builder that need to be ran daily, so I need something to kick off the updates (as you can't schedule these).
There are around 30k worth of records so a time based work flow is no good. From my googling it looks like I need and Scheduled Apex Class to update all records in this object which in turn will run my processes.

Can someone help me build the code to do this?
buggs sfdcbuggs sfdc

Here is sample code,which will help you,and let me know if you have strucked?
global class DailyLeadProcessor implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Lead> lList = [Select Id, LeadSource from Lead where LeadSource = null];
        if(!lList.isEmpty()) {
			for(Lead l: lList) {
				l.LeadSource = 'Dreamforce';
			update lList;

Once you finish the class, you can go to Setup -> App Setup  ->Develop -> Apex Classes and click on the "Schedule Apex" button and set up this class to run on the days/times you'd like. 

Hope this helps and welcome to Apex! (