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
M ParnellM Parnell 

Batching and Scheduling using Apex

global class SendReminderEmail implements Database.Batchable<sObject>{
	global String query;
	global String subject;
	global String body;	
}
	global SendReminderEmail(String query, String subject, String body){ 
		this.query = query;
    	this.subject = subject;
    	this.body = body;
}

    global Database.QueryLocator start(Database.BatchableContext bc) {
		return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext bc, List<Speaker__c> scope) {
    for (Speaker__c speaker : scope) {
        EmailManager.sendMail(speaker.Email__c, this.subject, this.body);
    }
}

    global void finish(Database.BatchableContext bc) {

    }
In Step 4 of this project exercise, the constructor global SendReminderEmail(String query, String subject, String body) is throwing an error that 'global' is an unexpected token. My complete code is featured above.
 
Mahesh DMahesh D
Remove the global as you already declared the class as global.

Regards,
Mahesh
M ParnellM Parnell
I removed the 'global' declaration and received an error that an unexpected token was found for 'SendReminderEmail' on the same line. Respectfully, MaryPearl J. Parnell | Desktop Support/Salesforce Administrator Pana-Pacific 838 N. Laverne Ave. Fresno, CA 93727 Office: 559-457-4765 | Mobile: 559-575-5337 marypearl.parnell@thebrixgroup.com | www.panapacific.com [pana_color for e-mail] CONFIDENTIALITY NOTE: The information contained in this email and in any attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. The recipient should check this email and any attachments for the presence of viruses. Sender accepts no liability for any damages caused by any virus transmitted by this email. If you have received this email in error, please notify us immediately by replying to the message and delete the email from your computer. This e-mail is and any response to it will be unencrypted and, therefore, potentially unsecure. Thank you. The Brix Group. P Please consider the environment before printing this email. Thank you.
Mahesh DMahesh D
Sorry, you closed the class at line 5, keep the same code which you have earlier and close the class properly.
 
global class SendReminderEmail implements Database.Batchable<sObject>{
	global String query;
	global String subject;
	global String body;	

	global SendReminderEmail(String query, String subject, String body){ 
		this.query = query;
    	this.subject = subject;
    	this.body = body;
}

    global Database.QueryLocator start(Database.BatchableContext bc) {
		return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext bc, List<Speaker__c> scope) {
    for (Speaker__c speaker : scope) {
        EmailManager.sendMail(speaker.Email__c, this.subject, this.body);
    }
}

    global void finish(Database.BatchableContext bc) {

    }
}